Skip to content

Statement timeout in transaction returns a broken connection to the pool #566

@joux3

Description

@joux3

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

  1. run a transaction
  2. cause a statement timeout in that transaction
  3. 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:

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
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions