-
Notifications
You must be signed in to change notification settings - Fork 216
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
Statement timeout in transaction returns a broken connection to the pool #566
Comments
That code was an attempt to mediate a long-standing issue in the driver. And as such, it is, of course, not perfect, I only provided for the most common cases of losing a connection during a long transaction. If you have a different case, and can offer an improvement over this work-around, a PR is welcome. Ideally, we all want to see the issue fixed in the driver, but I'm tired of chasing it, without result. |
P.S. There is a chance that this PR resolved the original issue, but it needs a thorough testing. |
That does seem annoying, thanks for your hard work shielding us users from dependency issues. I presume pg-promise could just issue rollbacks on any transaction error unless the driver was broken in this way. I opened PR #568 with statement timeout special case handling. |
@joux3 as per my comments earlier, there is a chance that the whole issue was resolved in the latest driver. So please try this first: function isConnectivityError(err) {
return false;
} and see if your error still happens or not. |
Always returning Luckily this issue does not cause me to hurry: I could work around this specific issue in my specific case by using a task instead of a transaction, which of course is not always possible. Is there something I could do the help test the driver changes? At least modifying the repro case to an actual |
@joux3 After applying all the latest updates, some tests and considerations, I ended up implementing the very same change as was originally in your PR. The reason is, even though the library now can work without function It was all released in version 8.5.3. |
Expected behavior
After a statement timeout in transaction, the used connection will be working properly when used again from the pool.
Actual behavior
pg-promise does not rollback the transaction when a statement timeout has happened in it. This connection will be in a transaction aborted state and next user of it from the pool can not run any queries.
Steps to reproduce
Here is a repro case: https://gist.github.com/joux3/a29727968f7195eb640959013fab319f
Environment
Extra info
The
code
field for the statement timeout error is57014
. This causes the rollback not the be issued:pg-promise/lib/utils/index.js
Lines 229 to 238 in ee34110
The text was updated successfully, but these errors were encountered: