-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make client._queryable public #2026
Comments
Catch the |
So, pg-pool should already remove non-queryable connections automatically from the pool, right?
AFAIK, pg-promise is using pg-pool, so I wonder why the broken connection is then reused. |
Well, I agree that the pool should remove clients that errorred automatically. |
@vitaly-t can you please clarify: From the code that I've pasted above and the comment from @charmander, it seems that pg-pool is already doing the right thing. |
This looks like a bug in the And so I had (within pg-promise) to add @brianc, @charmander What do you think about this, guys? |
@vitaly-t I agree that the pool should check for errored clients to avoid misuse, but there’s either an error event that’s being incorrectly suppressed here or another bug where an error event isn’t being emitted when |
Listening for an error, and ordering to kill the client are two separate things, they are not one block of code. And because of this, the client has to store the state somewhere first, and only then use it to signal the pool to kill the connection. This is very awkward, and therefore should be done on the lower level, by the same code which contains the dead connections, which in our case is the pool. The pool should never allow a successful request for a connection that's marked as non-queryable. |
@vitaly-t Like I said, I agree on what the pool should do, but in the meantime you should store the state yourself and not rely on a private field (the underscore means it’s private). |
I think when pull#2081 works as expected, this issue can be closed. |
Great! Thanks! |
Could you make client._queryable public?
i.e. I know that we can already access this variable, but I guess the
_
indicates that we shouldn't, and that this is an implementation detail, that can go away anytime.The use-case is that users of the lib (e.g. pg-promise), can use this info to decide if the client can be reused (e.g. released back to the pool) or if it is broken and should be killed.
Refrence to issue #680 of pg-promise
The text was updated successfully, but these errors were encountered: