Skip to content

Commit d849f29

Browse files
markhannumclaude
andcommitted
newsql_get_snapshot: fall back to stored snapshot on ha-retry
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>
1 parent ee66214 commit d849f29

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

plugins/newsql/newsql.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,13 @@ static int newsql_get_snapshot(struct sqlclntstate *clnt, int *file,
14061406
*file = sqlquery->snapshot_info->file;
14071407
*offset = sqlquery->snapshot_info->offset;
14081408
}
1409+
/* On ha-retry, statements after BEGIN (e.g. INSERT) carry no
1410+
* snapshot_info in their sqlquery. Fall back to the snapshot stored
1411+
* on the clnt during BEGIN handling, just as fill_snapinfo does. */
1412+
if (*file == 0 && clnt->is_hasql_retry && clnt->snapshot_file) {
1413+
*file = clnt->snapshot_file;
1414+
*offset = clnt->snapshot_offset;
1415+
}
14091416
return 0;
14101417
}
14111418

0 commit comments

Comments
 (0)