webmaxru / node-red-contrib-neo4j-bolt

A Node-Red node for Neo4j Bolt driver
https://www.npmjs.com/package/node-red-contrib-neo4j-bolt
Apache License 2.0
5 stars 4 forks source link

Neo4jError: Pool is closed, it is no more able to serve requests #9

Open cnoork opened 3 weeks ago

cnoork commented 3 weeks ago

Neo4j disconnect sometimes and will not reconnect automatically. The only way I found to solve this is by restart Node Red or change in security from the neo4j node the user to something not existent save and then change it back to the correct user.

Do I mis a setting somewhere or is this an issue?

cnoork commented 3 weeks ago

In Node Red the node keeps the status "Connected: 10 sessions"

webmaxru commented 3 weeks ago

Hello! Thanks for submitting this issue!

I call for help from @bonnydeal and @fasblom who contributed the latest updates to this library. Could you have a look, please?

fasblom commented 3 weeks ago

Hi,

I've also gotten this problem. From my memory I think I managed to fix it on another neo4j driver a couple of years ago and it had something to do with session.close and driver.close if I remember correctly.

Might be something here https://stackoverflow.com/questions/55372212/what-is-the-proper-way-to-close-a-session-using-neo4j-javascript-driver .

I am rather busy the coming weeks in case anyone looks at this first.

I think this could be related to how session.close or driver.close is implemented

fasblom commented 1 week ago

@cnoork - have you been able to reproduce this problem consistently? I've not been able to do it but it seems to occur rather randomly.

That said I've tried to implement a session.close based on the connection pool in this branch - if @webmaxru can have a look it might fix the problem https://github.com/fasblom/node-red-contrib-neo4j-bolt/tree/Session-close-work-in-progress

webmaxru commented 1 week ago

Thanks for your fix proposal, @fasblom! Yes, as it's not consistently reproducible issue it might require some extra "battletesting" before publishing.

@cnoork could you try to run experimental branch referenced by @fasblom above in your test/dev environment to check if the issue pops up (or not) and no other regressions happen?

cnoork commented 1 week ago

Thanks for the fast response. I have upgraded to version 2.5.2 and it looks like I don't get the messages anymore when I have moved/modified the neo4j function in my flow. It looks like that was the moment it mainly happend.

fasblom commented 1 week ago

I just got the error in 2.5.2 but still not clear how to reproduce. This happened after starting a docker container with node red in the morning, the day after when opening up the container it shows the Neo4jError: Pool is closed, it is no more able to serve requests. error when trying to execute a flow with the node red module in it. So it could relate to some kind of timeout that happens after inactivity.

I managed to get a bit more traces out:

Neo4jError: Pool is closed, it is no more able to serve requests.

    at captureStacktrace (/usr/src/node-red/data/node_modules/neo4j-driver-core/lib/result.js:624:17)
    at new Result (/usr/src/node-red/data/node_modules/neo4j-driver-core/lib/result.js:112:23)
    at Session._run (/usr/src/node-red/data/node_modules/neo4j-driver-core/lib/session.js:215:16)
    at Session.run (/usr/src/node-red/data/node_modules/neo4j-driver-core/lib/session.js:180:27)
    at Neo4jBolt._inputCallback (/usr/src/node-red/data/node_modules/node-red-contrib-neo4j-bolt/neo4j.js:92:23)
    at /usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/usr/src/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at Node.emit (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)
    at Node.receive (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:499:10)
webmaxru commented 1 week ago

Hmm. I checked for this issue in neo4j-driver-code https://github.com/neo4j/neo4j-javascript-driver/issues?q=is%3Aissue+%22Pool+is+closed%22 and found it: https://github.com/neo4j/neo4j-javascript-driver/issues/676 @fasblom Could you try this approach in your experimental branch?