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

fix: prevent reuse of broken connections in postgres pool #7792

Merged

Conversation

imnotjames
Copy link
Contributor

@imnotjames imnotjames commented Jun 23, 2021

Description of change

fixes #5112

passes the error back to the pg-pool release callback.

there aren't tests, though - because we don't really do mocking of the database for our tests & forcing a failing database is rather difficult. until we can more gracefully do mocks / spies / etc, I'm not sure the best way to verify this functionality.

I did verify it by running a long running query, kill -TERMing the postgres database & then observing the code flow.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@imnotjames imnotjames force-pushed the fix/5112/prevent-postgres-reusing-broken branch from fb01d9d to d655e05 Compare June 23, 2021 21:11
this updates the error handler we have on the postgres connection
object to release back with an error in the case of an error so
the underlying `pg-pool` knows to remove the connection from the
rotation
@imnotjames imnotjames force-pushed the fix/5112/prevent-postgres-reusing-broken branch from d655e05 to 7ed816e Compare June 23, 2021 22:00
@imnotjames imnotjames merged commit 5cf368a into typeorm:master Jun 28, 2021
@imnotjames imnotjames deleted the fix/5112/prevent-postgres-reusing-broken branch June 28, 2021 09:07
bryfox added a commit to bryfox/typeorm that referenced this pull request Jul 16, 2022
This extends github PR typeorm#7792 to pass the error, if any, to the release
callback from `pg-pool`. This should be done to ensure the connection is
removed from the pool, as described in typeorm#5112.
@bryfox bryfox mentioned this pull request Jul 16, 2022
7 tasks
pleerock pushed a commit that referenced this pull request Aug 24, 2022
This extends github PR #7792 to pass the error, if any, to the release
callback from `pg-pool`. This should be done to ensure the connection is
removed from the pool, as described in #5112.
wirekang pushed a commit to wirekang/typeorm that referenced this pull request Aug 25, 2022
This extends github PR typeorm#7792 to pass the error, if any, to the release
callback from `pg-pool`. This should be done to ensure the connection is
removed from the pool, as described in typeorm#5112.
nordinh pushed a commit to nordinh/typeorm that referenced this pull request Aug 29, 2022
This extends github PR typeorm#7792 to pass the error, if any, to the release
callback from `pg-pool`. This should be done to ensure the connection is
removed from the pool, as described in typeorm#5112.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken Postgres clients are released back into the pool, but should be removed
1 participant