Skip to content

Clients with aborted transactions taint the pool #154

@andrewdep

Description

@andrewdep

I have an issue that begins with a bug in our code. It's easy enough for us to fix our code, but I'm not sure if it is also a bug in node-postgres. The issue is if you get a Client from the pool, pauseDrain it, start a transaction, execute a query that results in an error (which puts the transaction into an aborted state), but fail to roll the transaction back before resumeDrain is called, then the Client is returned to the pool in an aborted transaction state. The next user to get that particular Client from the pool will have Postgres errors thrown at them: "current transaction is aborted, commands ignored until end of transaction block"
I know the pooling APIs I've used in other languages clean up connections before returning them to the pool, which would prevent this sort of thing, but I'm not sure what node-postgres' philosophy is on this?
Anyway, here is a commit on a fork I made with a test to reproduce the issue: andrewdep@832e48a
If you think it's right for this project, I can do a pull request for the test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions