Skip to content

fix: COPY sent via extended protocol with Sync can block server re-use in transaction mode#886

Open
levkk wants to merge 2 commits intomainfrom
levkk-fix-conn-stuck-copy-extended
Open

fix: COPY sent via extended protocol with Sync can block server re-use in transaction mode#886
levkk wants to merge 2 commits intomainfrom
levkk-fix-conn-stuck-copy-extended

Conversation

@levkk
Copy link
Copy Markdown
Collaborator

@levkk levkk commented Apr 10, 2026

The following sequence of messages can make a server be stuck in "unfinished state", blocking its re-use by other clients:

Parse("COPY t FROM STDIN")
Bind
Execute
Sync # This message is ignored by Postgres but not by pgdog
CopyData
[...]
CopyDone
Sync

The Sync sent after Execute is not necessary, but we record it and expect a ReadyForQuery from the server which only arrives after the second Sync is sent. An additional ReadyForQuery message remains in our internal state, and server.done() never returns true, causing the server to be tied to the client until it disconnects.

Related #885

@levkk levkk changed the title fix: COPY sent via extended protocol with Sync can block server fix: COPY sent via extended protocol with Sync can block server re-use in transaction mode Apr 10, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/backend/protocol/state.rs 0.00% 9 Missing ⚠️
pgdog/src/backend/server.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@NikolayS
Copy link
Copy Markdown
Contributor

is it a good idea to have a couple of tests where we know it's a problem – eg for tokio-postgres or postgres.js?

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