-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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.