Fix UNPREPARED handling in ResponseFuture to allow recovery on query ID mismatch#726
Draft
Copilot wants to merge 2 commits intoscylladb-27657-v2from
Draft
Fix UNPREPARED handling in ResponseFuture to allow recovery on query ID mismatch#726Copilot wants to merge 2 commits intoscylladb-27657-v2from
Copilot wants to merge 2 commits intoscylladb-27657-v2from
Conversation
8 tasks
…QueryNotFound Co-authored-by: mykaul <4655593+mykaul@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix UNPREPARED handling in the Python driver execution path
Fix UNPREPARED handling in ResponseFuture to allow recovery on query ID mismatch
Mar 4, 2026
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.
The original
PreparedQueryNotFoundhandler crashed withAssertionErrorwhen the server returned a query ID that differed from the localprepared_statement.query_id, permanently blocking reprepare/retry even when enough context existed to recover.Root cause
Two additional defects in the same block:
query_id.encode('hex')— Python 2 syntax, raisesAttributeErrorin Python 3._prepared_statements[query_id] = ...— not thread-safe; bypasses_prepared_statement_lock.Changes
cassandra/cluster.py— Remove the assertion; use server-returned ID for cache lookup first, fall back to in-flightprepared_statementwhen the lookup misses; useadd_prepared()for thread-safe cache writes; fix log calls tohexlify(...).decode('ascii')for clean string output.tests/unit/test_response_future.py— Addtest_prepared_query_not_found_uses_local_prepared_context(regression: raisesAssertionErroron old code when server returns a different query ID) andtest_prepared_query_not_found_prefers_returned_id_from_cache(validates cache-resolved statement takes precedence over local context). Docstring on the regression test explicitly documents the pre-fix failure mode.Pre-review checklist
./docs/source/.Fixes:annotations to PR description.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.