Skip to content

fix(pg): mark client not queryable on FATAL or PANIC error messages - #3830

Open
princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-fatal-error-queryable
Open

princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-fatal-error-queryable

Conversation

@princejain756

Copy link
Copy Markdown

Fixes #3826

When a PostgreSQL backend sends an ErrorResponse with severity set to 'FATAL' or 'PANIC' while an active query is running, the server closes the session immediately without sending ReadyForQuery. Previously, _handleErrorWhileQuerying routed the error to activeQuery.handleError without updating this._queryable, leaving client._queryable === true between the error callback firing and the TCP socket closing.

Any query issued inside the FATAL error callback was written onto a connection the server had already terminated, or allowed a pooled client to look reusable before end arrived.

This sets this._queryable = false in _handleErrorWhileQuerying when msg.severity === 'FATAL' || msg.severity === 'PANIC', while leaving normal 'ERROR' responses untouched.

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.

pg-pool hands a client out again after the server ended its session with a FATAL during a query

1 participant