Repository navigation
fix(postgres): prevent crash if postgres connection fails immediately (v6) - #14731
Merged
Merged
Conversation
schmod
commented
Jul 8, 2022
ephys
approved these changes
Jul 9, 2022
ephys
left a comment
Member
There was a problem hiding this comment.
This looks like a good change. Thank you for the PR!
I don't see how we would go about writing a test to prevent a regression either unfortunately
I see this is targeting v6. In order to avoid losing this PR in v7, could you also make a PR that targets main?
Contributor
Author
|
v7/main PR: #14731 (Apologies if I did this in the wrong order!) |
Member
|
Thanks for the two PRs! |
Contributor
|
🎉 This PR is included in version 6.21.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please make sure to review and check all of these items:
yarn testoryarn test-DIALECTpass with this change (including linting)?Description Of Change
We recently observed a crash due to an unhandled
Connection terminated unexpectedlyexception originating from thepglibrary. As best as I've been able to tell, this shouldn't be possible, and I've had difficulty reproducing it.However, upon reading through the current implementation of the Postgres connection-manager, I noticed that we don't immediately attach an error-handler to the
pgconnection.Based off of my reading of this code, it actually seems reasonably possible that an error emitted during either of the setup queries could trigger a hard crash. Moving the error-handler to an earlier phase of the connection's lifecycle should, in theory, make this a bit safer, and guard against any errors that are emitted very early in the connection's lifecycle.
Given the difficulty associated with reproducing this issue, I haven't been able to write an automated test-case to reproduce the issue or validate the fix. However, I'm reasonably confident that this fix is safe, and unlikely to make anything worse.
Todos