Skip to content

fix: ProtocolOutOfSync error#876

Open
meskill wants to merge 5 commits intomainfrom
fix/protocol-out-of-sync
Open

fix: ProtocolOutOfSync error#876
meskill wants to merge 5 commits intomainfrom
fix/protocol-out-of-sync

Conversation

@meskill
Copy link
Copy Markdown
Contributor

@meskill meskill commented Apr 7, 2026

More details are in the https://github.com/pgdogdev/pgdog/pull/876/changes#diff-fa25f12c8c64f8778cd0849682b0310883829c9eed403e4cde728e08ff980f29

The pr fixes couple of issues that could potentially cause the unexpected ProtocolOutOfSync errors, but only the issue 1 looks like highly possible in the real environments.

Issue 1

The issue 1 is reproducible when prepared_statements = "full" and the error happens during PREPARE part of the query execution. After the PREPARE fail the previous code was dropping all the remaining expected codes from the stream and stopped. But the backend will actually return the errors for EXECUTE anyway and this error will appear as the response to some another query and maybe even for another client.

The nature of the issue makes it harder to trace since the failed state of protocol is passed back to pool where another connection picks it up and breaks.

The integration test integration/prepared_statements_full/protocol_out_of_sync_spec.rb reproduces the issue with different configuration and it shows the errors in the https://github.com/pgdogdev/pgdog/actions/runs/24104237887/job/70323280283

I'm not sure why the ci doesn't show all logs, but the server logs locally are
image

The fix is mostly inside https://github.com/pgdogdev/pgdog/pull/876/changes#diff-8495b645d11def521aee36a05448da7fc100d632e6ad513d04fb7a47512bd08d

Other

The other issues not that important, but I've tried to fix them anyway just to be sure. Also extend logs in case we'll still face the issue in the future.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 99.61832% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/backend/server.rs 99.25% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@blacksmith-sh

This comment has been minimized.

@meskill meskill marked this pull request as ready for review April 7, 2026 22:41
@meskill meskill force-pushed the fix/protocol-out-of-sync branch from 868131b to b246b84 Compare April 8, 2026 17:09
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.

1 participant