Repository navigation
Cover the outdated parts left on disk with the empty part of a drop range - #120980
Conversation
…ange
`removePartsInRangeFromWorkingSetAndGetPartsToRemoveFromZooKeeper` writes an
empty part covering the range it drops, so that a restart before the removed
parts are unlinked does not resurrect them. Its block range, level and mutation
version were derived from the active parts being removed only.
Parts that had been outdated earlier are still on disk - they are unlinked only
once `old_parts_lifetime` has passed - and the ones that no active part covers
(a part removed by `DROP PART`, or an empty part dropped in the background) are
seen by the part loader after a restart. `MergeTreePartInfo::contains` demands a
strictly greater level when the block ranges differ, so such a leftover whose
level is not below the level of the covering part is neither contained in it nor
disjoint from it, and `PartLoadingTree::add` throws `Part {} intersects previous
part {}. It is a bug or a result of manual intervention`. The table cannot be
attached, and when it happens during startup the server cannot start at all.
Take the leftovers inside the dropped block range into account as well when
computing the range, the level and the mutation version of the covering part.
Found by the `Stress test (arm_debug)` job on master, where concurrent
`ATTACH PARTITION FROM` / `REPLACE PARTITION` / `MOVE PARTITION` between two
tables (`04004_move_partition_bidirectional_deadlock`) left `1_17_17_1` on disk
next to a covering part `1_12_60_1`:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=bac1295e647c578c6f181ee07b693bcbe8daf328&name_0=MasterCI&name_1=Stress%20test%20%28arm_debug%29
Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [47857be] Summary: ✅
AI ReviewSummaryThis PR fixes the empty covering-part that Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit 47857be.
Changed lines: Changed C/C++ lines covered: 14/14 (100.00%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
…rts left `REPLACE PARTITION` into a partition whose parts were all dropped earlier reaches `removePartsInRangeFromWorkingSetAndGetPartsToRemoveFromZooKeeper` with an empty `parts_to_remove` and writes no covering part. It does not have to: `DROP PART` of the part that covered the others leaves an empty part of a higher level on top of them, so the leftovers still cover one another. The loader activates that empty part, not the data underneath it, and `grabOldParts` unlinks it only once everything it covers is gone (`EMPTY_PART_COVERS_OTHER_PARTS`). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
Wow! This is fantastic!
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120980&sha=4a3c11e3e89b36cd7bc4144c52835f0bb1f99188&name_0=PR&name_1=Stress%20test%20%28amd_asan_ubsan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. It is unrelated to this pull request (which only changes the block range of the empty part written by a drop range in thrown from It is a master failure, not a branch one — Tracking issue with a deterministic one-query reproducer and the root-cause analysis: #121254 |
|
A fix is already in progress: #121230 (opened 2026-09-20 19:41 UTC, It covers this carrier. The failing action here, Two things that are not linked on either thread yet:
#121254 puts the defect in the analyzer rather than in |
…er inside the dropped range The regression test `05229_replace_partition_covers_outdated_parts` only covers plain `MergeTree`. The new test builds the same state for `ReplicatedMergeTree`: a mutated part `1_1_1_0_2` removed by `DROP PART` stays on disk (cleanup is stopped) while the mutation is stuck on the only active part `1_0_0_0`. The covering part written by `REPLACE PARTITION` must take the mutation version of the leftover (`1_0_3_1_2`), otherwise (`1_0_3_1`) the table fails to attach after DETACH + ATTACH with "Part ... intersects previous part ...". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A retry of `INSERT` after an injected Keeper fault allocates a new block number, so the parts got different names than the ones the test refers to. Disable `insert_keeper_fault_injection_probability` for the inserts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Fixed the flaky |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120980&sha=bd5b410bfdba8b88ae6ea1eab2485697fd47fbe0&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%201%2F2%29 ( The other failures are unrelated to this PR: the |
|
The fix is in progress: #123790 (it includes the change from my #123774, closed in its favor). In its own run on It is not flaky: under a Replicated database the stored view qualifies the descendant |
REPLACE PARTITION(and theDROP_RANGEhandling ofReplicatedMergeTree) writes an empty part covering the range it drops, so that a restart before the removed parts are unlinked does not resurrect them. The block range, the level and the mutation version of that covering part were derived from the active parts being removed only.Parts that had been outdated earlier are still on disk — they are unlinked only once
old_parts_lifetimehas passed — and the ones that no active part covers (a part removed byDROP PART, or an empty part dropped in the background) are seen by the part loader after a restart.MergeTreePartInfo::containsdemands a strictly greater level when the block ranges differ, so such a leftover whose level is not below the level of the covering part is neither contained in it nor disjoint from it, andPartLoadingTree::addthrows:The table cannot be attached; when this happens while loading tables at startup, the server does not start.
The same mismatch also defeated the removal ordering in
grabOldParts, which keeps an empty covering part until everything it covers is gone — a part the covering part does not formally contain can be unlinked in any order.Now the leftovers inside the dropped block range are taken into account as well when computing the range, the level and the mutation version of the covering part.
Found by
Stress test (arm_debug)on master, where the concurrentATTACH PARTITION FROM/REPLACE PARTITION/MOVE PARTITIONof04004_move_partition_bidirectional_deadlockleft1_17_17_1on disk next to the covering part1_12_60_1, after which the server could not start:https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=bac1295e647c578c6f181ee07b693bcbe8daf328&name_0=MasterCI&name_1=Stress%20test%20%28arm_debug%29
The same failure (STID
3562-495d) has been appearing on master and in pull requests since July 2026. There is no tracking issue for it.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
Part ... intersects previous part ...when attaching aMergeTreetable afterREPLACE PARTITION, if parts outdated by an earlierDROP PARTwere still on disk. The server could fail to start because of it.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120980]
Version info
26.10.1.1611-master(included in26.10and later)