Repository navigation
Fix SYSTEM RESTORE REPLICA leaving a replica behind the table metadata version on concurrent restores - #127656
Conversation
…ncurrent restores SYSTEM RESTORE REPLICA raises the table's /metadata znode version to the highest metadata_version of the restored parts. It did that with plain SETs, after the table and the first replica were already visible, and without any replication log entry. A replica restored at the same time (ON CLUSTER) could copy the first replica, or read /metadata, before the raise finished; nothing ever moved it to the final version, so every ALTER on it failed with CANNOT_ASSIGN_ALTER. The SETs also raised the version BY the parts' version instead of TO it, so each restored replica added it again. Raise the version TO the target, in version-checked batches of at most MULTI_BATCH_SIZE SETs. Each batch also creates an ALTER_METADATA log entry of the version it reaches, in the same multi, so every version /metadata is published at has a log entry that carries every replica to it. The replica running the restore no longer sets its own metadata_version; it reaches the version by executing those entries, like the replica that runs an ALTER. A concurrent ALTER or restore makes the batch fail with ZBADVERSION; the loop re-reads the structure and continues, so nothing is overwritten. The failpoint rmt_restore_replica_pause_before_metadata_version_raise lets the test pause one restore right before the raise. Closes ClickHouse#127629 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the batched metadata version raise comment to one line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings) plus my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261023-214800 |
|
cc @alesapin @tavplubix, could you review this and add the |
|
Workflow [PR], commit [80e4c59] Summary: ✅
AI ReviewSummaryReviewed head Missing context / blind spots
Final Verdict✅ Approve — no new inline findings. Runtime evidence relies on the author's reported local results pending a completed CI run. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 39 s compile time in total, 8 of them have a recent master baseline. |
9e515f2
|
Backports to affected releases? |
|
Affected supported releases: 26.3, 26.8, 26.9 and 26.10. Each contains #96351 and none has this fix yet (26.4 to 26.7 are affected too, but out of support). I can't add labels on this repo, so The change cherry-picks cleanly onto 26.9 and 26.10. On 26.3 and 26.8 the only conflicts are adjacent failpoint declarations ( |
Backport #127656 to 26.10: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
Backport #127656 to 26.9: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
Cherry pick #127656 to 26.3: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
…ica behind the table metadata version on concurrent restores
Cherry pick #127656 to 26.8: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
…ica behind the table metadata version on concurrent restores
Backport #127656 to 26.8: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
Backport #127656 to 26.3: Fix `SYSTEM RESTORE REPLICA` leaving a replica behind the table metadata version on concurrent restores
…ica behind the table metadata version on concurrent restores
…ica behind the table metadata version on concurrent restores
…ica behind the table metadata version on concurrent restores
…lica behind the table metadata version on concurrent restores
Closes: #127629
Related: #125796
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
SYSTEM RESTORE REPLICAleaving a replica behind the metadata version of the table when the replicas were restored at the same time (for example withON CLUSTER) or one after another, after which everyALTERon that replica failed withCANNOT_ASSIGN_ALTER. Closes #127629.Description
On 26.3, restoring the replicas of a table with
SYSTEM RESTORE REPLICAat once (ON CLUSTER) or one after another leaves a replica behind the table's metadata version, and everyALTERon it fails withCANNOT_ASSIGN_ALTER.Since #96351 the restore raises the
/metadataznode version to the highest metadata version of the restored parts with plainSETs, after the table and its first replica are visible in Keeper, without a replication log entry. A replica restored concurrently copies the first replica before the raise ends, and nothing moves it to the final version later. TheSETs also raised it by the parts' version, not to it, so each restored replica added it again.The raise now goes to the target version, in version-checked batches of at most 100
SETs. Each batch multi also creates anALTER_METADATAlog entry of the version it reaches, so every replica, including one that copied an intermediate version, reaches the final one through the log. The restoring replica no longer writes its ownmetadata_version; it applies the entries, as after anALTER. A concurrentALTERor restore fails the version check, and the loop re-reads.Validation: the new integration test pauses one restore before the raise (failpoint) while the other one runs. Without the fix
/metadataends at 4, not 2 (master), or the second replica stays at version 0 and itsALTERfails with code 517 (master + #125796); with it, 20/20 runs pass. A table with 260 versions gets 3 entries (100, 200, 260) and both replicas reach 260.#125796 (open) fixes the sequential case: only the first replica raises the version. Raising to the target fixes that case here too; the PRs touch disjoint lines and merge in either order, and its two tests pass here with and without its change.
Workflow [PR]
Sync PR [sync-upstream/pr/127656]
Version info
26.11.1.711-master(included in26.11and later)