RESET PREPARED: clear the cache with default config, never reuse statement names - #1331
Open
IgorOhrimenko wants to merge 1 commit into
Open
RESET PREPARED: clear the cache with default config, never reuse statement names#1331IgorOhrimenko wants to merge 1 commit into
IgorOhrimenko wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
RESET PREPARED passed the configured prepared_statements_limit into close_unused(), and the default limit is unlimited — so out of the box the command removed nothing. Pass 0 explicitly: drop everything not in use, whatever the limit is. That exposed what close_unused(0) actually did: reset() the whole cache, dropping statements clients still hold and rolling the global name counter back to zero. A server connection that still has an old __pgdog_N prepared would then be handed a different query under the same name — the local cache check only compares names. The same path runs every second from maintenance when prepared_statements_limit is set to 0. close_unused(0) now removes only unused statements and never touches the counter; reset() is test-only. RESET PREPARED also had no parser test (RESET QUERY_CACHE did).
IgorOhrimenko
force-pushed
the
reset-prepared-clears-cache
branch
from
August 10, 2026 10:07
851d1d0 to
67e3c84
Compare
IgorOhrimenko
marked this pull request as ready for review
August 10, 2026 12:35
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 related defects in the prepared statements cache admin path, split out of #1311 so they can be reviewed on their own.
RESET PREPARED does nothing with the default config
ResetPrepared::execute()passedprepared_statements_limitintoclose_unused(), and the default limit is unlimited (i64::MAX) —len() - capacitysaturates to 0 and the command removes nothing. It now passes0explicitly: drop everything not in use, whatever the configured limit is.close_unused(0) wiped in-use statements and reused global names
close_unused(0)calledreset(): it dropped statements clients still hold and rolled the global name counter back to zero. After that, a server connection that still has an old__pgdog_Nstatement prepared can be handed a different query under the same name — the server-side cache check compares names only. The same path ran once a second from the maintenance task for anyone who setsprepared_statements_limit = 0.close_unused(0)now removes only unused statements and never touches the counter;reset()is#[cfg(test)].Testing
close_unused(0)keeps statements in use, removes released ones, and the next insert gets a fresh global name (fails on main: everything is wiped and the name is reused).RESET PREPAREDclears released statements under the default config (fails on main: no-op).RESET PREPARED—RESET QUERY_CACHEhad one, this command didn't.