Skip to content
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

Release called on client which has already been released to the pool #493

Open
kyle-apex opened this issue Feb 22, 2022 · 2 comments
Open
Labels

Comments

@kyle-apex
Copy link

Steps to reproduce

  1. Use loopback-connector-postgresql 5.5.0 (5.4.0 does not exhibit this issue)
  2. Commit a transaction with an error (ex: unique key violation)
  3. Rollback the transaction

Current Behavior

Calling transaction.commit and subsequently transaction.rollback if there is a commit error results in:

The following error from pg-pool in the rollback is uncaught and crashes the server: Release called on client which has already been released to the pool

I would expect the error to be caught (perhaps in PostgreSQL.prototype.releaseConnection?) and passed along without crashing the server

@kyle-apex kyle-apex added the bug label Feb 22, 2022
@kyle-apex
Copy link
Author

kyle-apex commented Feb 23, 2022

For others searching for this error, this override is getting me around this issue for now:

dataSource.connector.releaseConnection = function (connection, err) {
		if (typeof connection.autorelease === 'function') {
			connection.txId = null;
			connection.autorelease(err);
			connection.autorelease = null;
		} else {
			try {
				connection.release();
			} catch (err) {}
		}
	};

@marciocorrrea
Copy link

Hello, Thank you for your contribution.

I got the same error, in my case I applied the following solution.

loopback-connector-postgresql/lib/transaction.js

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants