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.
pg-pool requires attaching an error handler to each connection acquired from the pool, which will handle connection-level errors. Without it, the process ends up crashing whenever the connection is interrupted (e.g. database failover).
This fact can be observed in pg-pool:
This PR is in response to production outages we have faced during Aurora PostgreSQL failovers, with the unexpected disconnections for actively-used connections turning error emits into unhandled exceptions and ultimately crashing the entire NodeJS process, despite our existing error handlers on both
.on('error'
and.adapter.pg.on('error'
, and our catch-all try/catches.. With this patch in place, the unexpected disconnects (e.g. which could be simulated with atcpkill -9
) no longer crash the processes, proper errors are yielded by the queries - which can then be captured as usual, and the application can eventually recover once the database is available once again.See brianc/node-postgres#1324 (and more specifically the last few comments there).
Checklist
npm test
passes on your machine