Skip to content

fix: ProtocolOutOfSync error#887

Merged
levkk merged 3 commits intomainfrom
levkk-fix-out-of-sync-error
Apr 10, 2026
Merged

fix: ProtocolOutOfSync error#887
levkk merged 3 commits intomainfrom
levkk-fix-out-of-sync-error

Conversation

@levkk
Copy link
Copy Markdown
Collaborator

@levkk levkk commented Apr 10, 2026

This was caused by the following conditions:

  1. query_parser = "on", so SET statements are intercepted
  2. ruby-pg driver initialized with application_name: '' so it wouldn't run SET application_name TO x
  3. A query executed via extended protocol
  4. A bad parameter set manually via SET, e.g. SET lock_timeout to sdf
  5. Any query executed afterwards

This was caused by us not resetting extended protocol state in our protocol state machine and allowing invalid SET statements to be executed in a batch.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@levkk levkk merged commit 54c9d3a into main Apr 10, 2026
15 of 16 checks passed
@levkk levkk deleted the levkk-fix-out-of-sync-error branch April 10, 2026 08:48
conn = connect 'pgdog', 'pgdog'
conn.exec_params 'SELECT $1', [1]
conn.exec "SELECT 1"
conn.exec "SET lock_timeout TO sdfs"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas why the error is raised later and not here? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We intercept SET statements and execute them only when a real query is sent.

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