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(postgres): invalidate connection after client-side timeout #15283

Merged
merged 4 commits into from Nov 15, 2022

Conversation

harrykao
Copy link
Contributor

Merge ff43e8d from main:

The query_timeout feature of the pg package helps handle stuck TCP connections more quickly and gracefully by implementing a client-side timeout:

brianc/node-postgres#1713

Sequelize started passing this dialect-specific option through to pg here:

#13258

I believe we also want to invalidate the connection when a client-side timeout occurs. We shouldn't try to reuse the stuck connection because...it's stuck.

This PR updates the error handling code so that the connection is invalidated if the error matches the one thrown from here:

https://github.com/brianc/node-postgres/blob/5538df6b446f4b4f921947b460fe38acb897e579/packages/pg/lib/client.js#L529

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

Todos

Merge ff43e8d from main:

The `query_timeout` feature of the `pg` package helps handle stuck TCP
connections more quickly and gracefully by implementing a client-side
timeout:

brianc/node-postgres#1713

Sequelize started passing this dialect-specific option through to `pg` here:

sequelize#13258

I believe we also want to invalidate the connection when a client-side
timeout occurs. We shouldn't try to reuse the stuck connection
because...it's stuck.

This PR updates the error handling code so that the connection is
invalidated if the error matches the one thrown from here:

https://github.com/brianc/node-postgres/blob/5538df6b446f4b4f921947b460fe38acb897e579/packages/pg/lib/client.js#L529
Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the other tests pass I think we should be good. Thanks for backporting!

@harrykao
Copy link
Contributor Author

Assuming the other tests pass I think we should be good. Thanks for backporting!

No problem. Thanks for reviewing!

@WikiRik WikiRik merged commit a205765 into sequelize:v6 Nov 15, 2022
@github-actions
Copy link
Contributor

🎉 This PR is included in version 6.25.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants