Repository navigation
{186552229} Keep the sc_list when the master downgrades mid-DDL (fixing timepart_retro) - #6305
Open
WalidNejmi wants to merge 1 commit into
Open
WalidNejmi wants to merge 1 commit into
WalidNejmi wants to merge 1 commit into
Conversation
When the master downgrades while a multi-table DDL (such as a retroactive time partitioning) is running, bplog_schemachange_wait returns ERR_NOMASTER and frees the in-memory schema changes so that the new master can resume them from the sc_list saved in llmeta. OSQL_FLAGS_SCDONE was left set from the successful start, though, so the abort callback that runs next deleted that sc_list. Whether the delete reached the cluster depended on whether the old master still believed it was master when the callback ran: when it did, the new master found no sc_list, resumed nothing, and the partition was never created. timepart_retro failed this way in 5 of 12 runs. Clear OSQL_FLAGS_SCDONE on ERR_NOMASTER, as the start paths already do for SC_MASTER_DOWNGRADE. The resume finalize sets it again, so a resumed DDL still drops its sc_list once it commits or aborts. Signed-off-by: Walid Nejmi <wnejmi@bloomberg.net>
WalidNejmi
marked this pull request as ready for review
October 7, 2026 18:53
roborivers
approved these changes
Oct 7, 2026
roborivers
left a comment
There was a problem hiding this comment.
Cbuild submission: Success ✓.
Regression testing: Success ✓.
The first 10 failing tests are:
sc_truncate_multiddl_generated [db unavailable at finish] **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
This branch has not been deployed
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.
Summary
Fix a race where a master downgrade during a multi-table schema change could delete the persisted sc_list before the new master had a chance to resume it.
This showed up as a timepart_retro flake: the old master aborted the DDL, removed the resume state, and the new master found nothing to continue, so the retroactive partition shards were never created.
The fix clears OSQL_FLAGS_SCDONE on the ERR_NOMASTER path so the old master's abort callback preserves the sc_list. The new master can then resume the DDL and clean up the list normally when the operation finishes.
Background (if unfamiliar)
timepart_retroconverts an existing table into a retroactive time partition using the multi-table DDL path.For multi-table DDLs, Comdb2 persists an
sc_listin llmeta before starting the schema changes. If the master changes while the DDL is running, the new master uses this list to resume the operation.flowchart LR A[Old master starts multi-table DDL] --> B[Persist sc_list] B --> C[Schema change runs] C --> D[Master downgrades] D --> E[New master reads sc_list] E --> F[Resume DDL]Bug
When a schema change detected a master downgrade inside
bplog_schemachange_wait(), it returnedERR_NOMASTERand clearedsc_pending, intending to leave the persistent schema-change state for the new master.However,
OSQL_FLAGS_SCDONEremained set.The transaction then aborted and
osql_scdone_abort_callback()deleted the persistedsc_list. If that delete happened before the new master resumed the DDL, there was no state left to resume.flowchart TD A[Master downgrade during DDL] --> B[Return ERR_NOMASTER] B --> C[sc_pending cleared] C --> D[SCDONE still set] D --> E[Abort callback runs] E --> F[Delete sc_list] F --> G[New master finds no DDL to resume] G --> H[timepart_retro fails]This caused the flaky
timepart_retrofailure where the retroactive partition shards were never created.Fix
Clear
OSQL_FLAGS_SCDONEwhenbplog_schemachange_wait()returnsERR_NOMASTER:This prevents the old master's abort callback from deleting the
sc_list.The new master can then resume the DDL normally. Once the resumed operation finishes or fails, the normal resume path sets
SCDONEagain and performs the usual cleanup.flowchart TD A[Master downgrade] --> B[Return ERR_NOMASTER] B --> C[Clear sc_pending] C --> D[Clear SCDONE] D --> E[Abort callback preserves sc_list] E --> F[New master reads sc_list] F --> G[Resume DDL] G --> H[Normal commit or abort cleanup]This also matches the existing handling of
SC_MASTER_DOWNGRADEin the schema-change start paths.Testing
Before the fix,
timepart_retroreproduced the race intermittently, with 5 failures across 12 targeted runs.With the fix:
timepart_retro: 8/8 passessc_resume_partition: passtimepart_events: passsc_timepart: passDiagnostic runs also confirmed that after the fix the old master no longer deletes the
sc_list, and the new master consistently finds and resumes it.