-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Labels
Description
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
- run a transaction
- cause a statement timeout in that transaction
- try to reuse to connection and see that it fails
Here is a repro case: https://gist.github.com/joux3/a29727968f7195eb640959013fab319f
Environment
- Version of pg-promise: 8.5.2
- OS type (Linux/Windows/Mac): Mac
- Version of Node.js: 10.12.0
Extra info
The code field for the statement timeout error is 57014. This causes the rollback not the be issued:
Lines 229 to 238 in ee34110
| function isConnectivityError(err) { | |
| const code = err && typeof err.code === 'string' && err.code; | |
| const cls = code && code.substr(0, 2); // Error Class | |
| return code === 'ECONNRESET' || cls === '08' || cls === '57'; | |
| // Code 'ECONNRESET' - Connectivity issue handled by the driver. | |
| // Class 08 - Connection Exception. | |
| // Class 57 - Operator Intervention. | |
| // | |
| // ERROR CODES: https://www.postgresql.org/docs/9.6/static/errcodes-appendix.html | |
| } |