-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Pool: release called twice for the same resource #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please see the wiki under Client -> pauseDrain / resumeDrain https://github.com/brianc/node-postgres/wiki/Client Also, this code: https://github.com/brianc/node-postgres/blob/master/lib/client.js#L198 You need to call This is especially important if you're using the pool and want to do something like this:
In an async nature. |
I saw pauseDrain() in wiki, but Brian, think of another question - is it acceptable if my code causes an error somewhere deep in pool and there are no indication of that? No exceptions, no errors, just a line to the disabled by default log? Are the other issues to consider? |
node-pool is logging an error condition but not propagating that error outwards. If you look at https://github.com/brianc/node-postgres/blob/master/lib/index.js#L30 you'll see there's no place there where I'm suppressing or not propagating any errors from node-pool. It is handy to know returning a resource to the pool twice results in an error...but whether or not to actually emit an error event (or something similar) about this would be left up to the node-pool developer to decide. I think it might be a nice feature for the pool to actually emit an error instead of just logging it - I could pass that error up to user code and quell the concern you're raising here. |
* Test queued checkout after a connection failure Co-authored-by: Johannes Würbach <[email protected]> * Fix queued checkout after a connection failure Co-authored-by: Johannes Würbach <[email protected]>
That code produce no error indication if generic-pool logging is disabled (which is node-postgres default), but if I enable generic-pool logging and add
console.log('drain');
intoclient.on('drain', function()
innode-postgres/pg/lib/index.js
then I've got the following output:Also, no error occurs if I does not use
process.nextTick
. I use it to simulate async call to a different (not postgres) data source which may occurs in some cases.So, am I need to call
pg.connect
upon each database query? Or maybe it is better to manually manage database connections? I don't like that two options - in a typical HTTP request serving environment maybe that issue can be somehow resolved on your library level?Thanks.
The text was updated successfully, but these errors were encountered: