Skip to content

fix(pg): send Sync after error in paged queries - #3831

Open
princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-rows-error-sync
Open

princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-rows-error-sync

Conversation

@princejain756

Copy link
Copy Markdown

Fixes #3707

A query configured with rows (portal suspension) is driven by Flush rather than Sync: _getRows sends Execute(rows: N) plus connection.flush() on the initial dispatch and again after every PortalSuspended, and Sync only goes out from handleCommandComplete / handleEmptyQuery.

When the server answers ErrorResponse instead, it enters ignore-till-sync error recovery and withholds ReadyForQuery. The query itself rejects fine, but the client's readyForQuery flag stays false and every subsequent query queues forever.

This sends Sync from _handleErrorMessage when the active query is paged, so the backend exits error recovery and emits ReadyForQuery. The bind-error path in Query.prepare is unaffected: it already syncs before calling handleError, and that path never reaches _handleErrorMessage.

Added test/integration/gh-issues/3707-tests.js covering the report: division by zero mid-portal, followed by a select 1 that previously hung.

A query using the rows option drives the portal with Flush instead of Sync. When the server answers ErrorResponse it enters ignore-till-sync mode, so ReadyForQuery never arrives and the connection stays wedged: the failed query rejects but every queued query waits forever. Sending Sync when an ErrorResponse hits a rows-limited query lets the backend leave error recovery and emit ReadyForQuery again. Fixes brianc#3707.
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.

Error during a rows-limited query permanently wedges the connection — handleError sends no Sync

1 participant