Skip to content

fix: send Sync on error during rows-limited (portal) queries#3712

Open
houzhonglogic wants to merge 1 commit into
brianc:masterfrom
houzhonglogic:fix/handleerror-missing-sync
Open

fix: send Sync on error during rows-limited (portal) queries#3712
houzhonglogic wants to merge 1 commit into
brianc:masterfrom
houzhonglogic:fix/handleerror-missing-sync

Conversation

@houzhonglogic

Copy link
Copy Markdown

Problem

When a query with the rows option (portal suspension mode) encounters an ErrorResponse from the server, handleError returns the error to the caller but never sends Sync. The server stays in an extended-query subtransaction waiting for Sync, ReadyForQuery never arrives, and the connection is permanently wedged — every subsequent query on that client queues forever.

This was reported in #3707: "Error during a rows-limited query permanently wedges the connection — handleError sends no Sync".

Fix

handleCommandComplete already has the connection.sync() call for the rows path (line 93–94). handleError was simply missing the same check. This PR adds it.

Prior art

The pg-cursor package handles this correctly in its own error path. The main pg packages rows feature uses a different internal path and was overlooked.

Testing

pg-cursor already has error-handling tests that verify the connection recovers after a cursor error. The main packages rows path should have the same coverage — this fix brings it in line with cursor behaviour.

handleError was missing the connection.sync() call that
handleCommandComplete already has for the rows-limited path.

When a query with the rows option hits an ErrorResponse from
the server, handleError returns the error to the caller but
never sends Sync. The server stays in an extended-query
subtransaction waiting for Sync, ReadyForQuery never arrives,
and the connection is permanently wedged — every subsequent
query on that connection queues forever.

handleCommandComplete has had this sync call since rows support
was added. handleError simply forgot to do the same.

Refs: 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.

2 participants