Repository navigation
fix: copy-in transaction status and Sync handling - #466
Merged
Merged
Conversation
… FROM STDIN A successful simple-protocol CopyDone always answered ReadyForQuery(Idle), so a COPY run inside BEGIN made clients that track the transaction state from ReadyForQuery believe the transaction had ended. Co-authored-by: Cursor <cursoragent@cursor.com>
redox
force-pushed
the
altertable/v0.38.3
branch
from
September 28, 2026 15:19
5818284 to
f3c63fa
Compare
rust-postgres pipelines a Sync right after the Execute that starts a COPY FROM STDIN, before any CopyData. Since sunng87#465 that Sync aborted the copy with 08P01, breaking every extended-protocol copy from that client. PostgreSQL ignores Flush and Sync in copy-in mode for exactly this reason. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Amazing to read! Looking forward to next release 🚀 |
Owner
|
Just pushed a patch release with this. Thank you! |
Contributor
Author
Absolutely! Trying to make Fivetran work with https://altertable.ai/ and the postgres adapter in front of our lakehouse (until we have a proper destination in Fivetran). |
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.
Two fixes to the copy-in sub-protocol, both found running pgwire behind an ETL tool that loads data with
BEGIN; COPY ... FROM STDIN; COMMIT.1. Report the tracked transaction status after a simple-protocol COPY
When a
COPY ... FROM STDINstarted from a simpleQuerycompletes, the server always answersReadyForQuery(Idle), regardless of the connection's transaction state.The transaction is still open on the server, but clients that track the transaction state from
ReadyForQuery(libpq'sPQtransactionStatus, pgjdbc, ...) now believe it has ended.2. Ignore
FlushandSyncduring copy-in, like PostgreSQLSince #465 (unreleased), a
Syncreceived during copy-in aborts the copy with08P01. rust-postgres (tokio-postgres) pipelinesBind, Execute, Syncbefore sending anyCopyData, so every extended-protocolCOPY FROM STDINfrom it now fails with "unexpected message type during COPY".PostgreSQL ignores these messages. From the protocol docs:
The
CopyInProgressstate now ignoresFlushandSync; any other non-copy message still aborts the copy. The terminatingSyncafterCopyDoneis still routed toon_syncas introduced in #465.