newsql_get_snapshot: fall back to stored snapshot on ha-retry#6079
Open
markhannum wants to merge 1 commit into
Open
newsql_get_snapshot: fall back to stored snapshot on ha-retry#6079markhannum wants to merge 1 commit into
markhannum wants to merge 1 commit into
Conversation
On an ha-retry, is_snap_uid_retry sets clnt->is_hasql_retry=1 and stores the retry snapshot LSN in clnt->snapshot_file/offset during BEGIN handling. Statements after BEGIN (INSERT, SELECT, COMMIT) carry no snapshot_info in their sqlquery because only the BEGIN carries it from the client. initialize_shadow_trans calls newsql_get_snapshot to obtain the snapshot LSN. Without a fallback, newsql_get_snapshot returns file=0 for these in-transaction queries, causing trans_start_serializable to be called with file=0 and is_ha_retry=1 — which triggers the assertion at bdb_osqltrn.c:278 and crashes the node. fill_snapinfo already handles this correctly by checking clnt->snapshot_file when is_hasql_retry is set. Add the same fallback to newsql_get_snapshot so that initialize_shadow_trans always uses the correct retry snapshot. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
roborivers
approved these changes
Jul 21, 2026
roborivers
left a comment
There was a problem hiding this comment.
Cbuild submission: Success ✓.
Regression testing: Success ✓.
The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
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.
Problem
On an HA retry (
is_hasql_retry=1), the client replays the transactionstarting from the snapshot LSN that was established during the original
BEGIN. That LSN is stored inclnt->snapshot_file/offsetbyis_snap_uid_retryatBEGINtime.Statements after
BEGIN(INSERT, SELECT, COMMIT) carry nosnapshot_infoin theirCDB2SqlQueryprotobuf because only theBEGINmessage carries it from the client.
newsql_get_snapshotwas notchecking
clnt->snapshot_fileas a fallback, so it returnedfile=0for all post-BEGIN statements on a retry path.
initialize_shadow_transpasses that file/offset intotrans_start_serializable. Whenfile=0andis_ha_retry=1,the assertion at
bdb_osqltrn.c:278fires and kills the node.Because the assertion is in common code reached by every thread, all
three nodes crash simultaneously.
Root cause
newsql_get_snapshot(plugins/newsql/newsql.c) only copiedsnapshot_infofrom the currentsqlquery. It had no fallback forthe retry case, unlike
fill_snapinfowhich already handled this bychecking
clnt->snapshot_filewhenis_hasql_retryis set.Fix
Add the same fallback to
newsql_get_snapshot: when*fileis still 0after checking
sqlquery->snapshot_info, andclnt->is_hasql_retryisset, use
clnt->snapshot_file/offsetinstead. This mirrors theexisting logic in
fill_snapinfoand makes the two paths consistent.Testing
Reproduced with a 3-node cluster under election / network-partition
stress (jepsen-style nemesis testing). The
assert(file)crash atbdb_osqltrn.c:278no longer fires after this change.Files changed
plugins/newsql/newsql.c— 7-line addition innewsql_get_snapshot