Skip to content

feat: reprepare and retry prepared statements#970

Open
dowzhong wants to merge 8 commits into
pgdogdev:mainfrom
dowzhong:feat/iss934-reprepare-statements
Open

feat: reprepare and retry prepared statements#970
dowzhong wants to merge 8 commits into
pgdogdev:mainfrom
dowzhong:feat/iss934-reprepare-statements

Conversation

@dowzhong
Copy link
Copy Markdown

@dowzhong dowzhong commented May 8, 2026

#943

My attempt at implementing automatic reprepare+retry of prepared statements that hit a cache error.

I thought the place place to do this would be in the server impl. That way, we can avoid dealing with sharding and duplicating the retry logic at different points. Please let me know if I should move it elsewhere though.

The main piece of work here is a small state machine in each server that keeps track of what the current batch of messages are, and if they've returned with expected. That way, we can know which messages we need to retry, and which messages we shouldn't send again. An example being

Parse
Describe
--- later ---
Describe
Bind <-- cache error happens here
Execute
Sync

In this case, we want to reprepare and only retry from bind onwards.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 8, 2026

CLA assistant check
All committers have signed the CLA.

@dowzhong dowzhong marked this pull request as draft May 8, 2026 15:48
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 93.19527% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/backend/server_state.rs 80.21% 18 Missing ⚠️
pgdog/src/backend/server.rs 98.73% 3 Missing ⚠️
pgdog/src/backend/prepared_statements.rs 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dowzhong dowzhong marked this pull request as ready for review May 11, 2026 09:59
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