Repository navigation
Disable regular merges in 03518_alter_logical_race so the ALTER's mutation is not starved - #114028
Conversation
The test fails on Stateless tests (amd_debug, parallel) with TIMEOUT: ALTER TABLE alter_table DROP COLUMN h NO ALTER PROGRESS: completed zero full ALTER ADD/MODIFY/DROP cycles i.e. its own progress guard firing because no ALTER worker completed a cycle. DROP COLUMN and MODIFY COLUMN on a physical column require a data mutation (AlterCommands.cpp isRequireMutationStage), and StorageReplicatedMergeTree::alter waits for it. A replicated mutation only advances when the merge-selecting task creates a MUTATE_PART entry per part, but try_assign_merge attempts a regular merge FIRST and returns AttemptStatus::EntryCreated at StorageReplicatedMergeTree.cpp:4505, before control reaches the mutation selection block at :4531-4560, then reschedules immediately at :4590-4591. This test's concurrent INSERT stream keeps mergeable ranges permanently available, so every selector pass is spent on a merge and the mutation is starved. In the failing run 2471 MERGE_PARTS entries were created against 44 MUTATE_PART, with the mutation rate decaying from 41 to 0 entries per minute as the part population grew. Strict alter-version ordering (ReplicatedMergeTreeAltersSequence::canExecuteMetaAlter) then prevented the second worker from applying even its DROP's metadata, which is why zero cycles completed rather than one. PR ClickHouse#108060 chased this one layer too shallow: it unpinned the mutation count throttles (max_replicated_mutations_in_queue, number_of_free_entries_in_pool_to_execute_mutation), but a mutation that never reaches the selection block never consults them. Neither limit fired in this run. Disable regular merges for the table instead. max_bytes_to_merge_at_max_space_in_pool = 0 short-circuits getMaxSourcePartsBytesForMerge, so can_assign_merge is false and control falls through to mutation selection on every pass. Mutations are unaffected: that path reads getMaxSourcePartBytesForMutation, a different function. With merges off parts accumulate unmerged, so parts_to_delay_insert and parts_to_throw_insert are raised above the per-partition defaults (1000/3000) to keep the test's INSERT side from being delayed or rejected, which would break the INSERT progress guard. max_parts_in_total (100000, whole-table) is left alone. 04652_mutate_part_ahead_of_table_metadata_version.sh uses the same setting on ReplicatedMergeTree for the same purpose. SYSTEM STOP MERGES is table-scoped and would not need no-parallel, but it is still not usable here: it takes the merges_blocker action lock, and ReplicatedMergeTreeQueue::shouldExecuteLogEntry applies that lock to MUTATE_PART as well as MERGE_PARTS, so it would block the mutation this needs to let through. No assertion is weakened: the test asserts ALTER cycle progress, INSERT progress and an empty reference, and nothing reads system.parts, part counts or merge state. The trade is narrower than "no coverage lost": with merges off this test no longer exercises the merge-side column resolution path (MERGE_PARTS 33152 to 0 over the two 50x arms), while the mutation-side path is exercised 5.7x more (MUTATE_PART 4958 to 28249). The merge arm under concurrent ADD/DROP COLUMN stays covered by 01079_parallel_alter_add_drop_column_zookeeper.sh and 03144_parallel_alter_add_drop_column_zookeeper_on_steroids.sh, which keep merges enabled and additionally force them with OPTIMIZE TABLE ... FINAL. The ALTERs still carry no IF [NOT] EXISTS, so NOT_FOUND_COLUMN_IN_BLOCK or DUPLICATE_COLUMN would still fail the run, and the progress guard keeps full strength. Raising MAX_TIMEOUT was rejected: the starved mutation was decelerating with no bound, and the healthy amd_debug p50 is 11.7s against this run's 182s. Validated on one box under identical load, with only the test file differing: pristine master fails 5/50 under tests/clickhouse-test --test-runs 50, carrying the exact signature above; with this change 50/50 pass on debug and 50/50 on ASAN. p95 drops from 77.5s to 32.7s and no run reaches the 180s hard deadline. Confirmed the settings took effect rather than being silently ignored (0 MERGE_PARTS and 28249 MUTATE_PART entries across the 50 debug runs, 0 and 23359 on ASAN) and that no Too many parts or insert delay line appeared in either. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111534&sha=b8c37b85647510a9b374b77fadaeeddd8ab957f5&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29
Internal second-model review (2 rounds, no blockers)An independent model reviewed this change cold against the source; I adjudicated its findings.
My first-round answer was that a completed The finding still does not hold, for a different reason. It needs every completed cycle to run Measured across all 101 validation runs (51 debug + 50 ASAN, counted per runner database), the The proposed 💡 Round 1 also corrected two commit-message claims that were right in conclusion but wrong in Session id: cron:clickhouse-review-slot-48:20260809-103700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260809-044400 |
|
cc @Michicosun, could you review this? The test's concurrent INSERTs keep mergeable ranges always available, so the merge-selecting task returns EntryCreated on a regular merge before ever reaching mutation selection, and the ALTER's mutation starves (2471 MERGE_PARTS against 44 MUTATE_PART); disabling regular merges for the test table lets it through. |
|
Workflow [PR], commit [78c1a6e] Summary: ❌
AI ReviewSummaryThis PR updates Final Verdict✅ No findings. |
CI finish ledger — 78c1a6eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260809-210000 |
d65909c
…erges `PARTITION BY b % 10` with a per-row `rand(2)` made every 1000-row INSERT write 10 parts. ClickHouse#114028 disabled regular merges for this table so that merges stop starving the ALTER's mutation, which removed the only bound on the part count: each later ALTER mutation then has to rewrite every part inserted before it, at one MUTATE_PART entry per merge-selecting pass, and the last one of the chain can exceed the 120 s client timeout (`TIMEOUT: ALTER TABLE alter_table DROP COLUMN i` on arm_binary, with 2419 and 1178 parts to rewrite in the two failing runs). Both failure modes come from the 10-parts-per-INSERT rate, so cut it at the source: `randConstant(2)` puts every INSERT into one partition (one part per INSERT) while successive INSERTs still spread over all 10 partitions, and regular merges are re-enabled by dropping max_bytes_to_merge_at_max_space_in_pool, parts_to_delay_insert and parts_to_throw_insert. The ClickHouse#108060 throttle overrides stay, as do the deadlines and the progress guards. Local server with the CI test config, master file vs this change: 10.0 vs 1.0 parts per INSERT; slowest ALTER p95 66.5 s vs 5.6 s at -j4; on the release build at -j10, 1/100 TIMEOUT vs 0/100 and 107 s vs 6.6 s. The pre-ClickHouse#114028 file fails 14/50 at -j24 with NO ALTER PROGRESS; this change passes 50/50 there and 50/50 on ASAN. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
03518_alter_logical_racefails onStateless tests (amd_debug, parallel)withTIMEOUT: ALTER TABLE alter_table DROP COLUMN hplusNO ALTER PROGRESS: completed zero full ALTER ADD/MODIFY/DROP cycles, its own progress guard firing(CI report).
Root cause:
DROP/MODIFY COLUMNon a physical column needs a data mutation, which advancesonly when the merge-selecting task creates a
MUTATE_PARTentry per part.try_assign_mergetries a regular merge first and returns
EntryCreatedbefore reaching mutation selection, thenreschedules immediately. This test's concurrent INSERTs keep mergeable ranges permanently
available, so every pass goes to a merge and the mutation starves: 2471
MERGE_PARTSagainst 44MUTATE_PART. Strict alter-version ordering then blocks the second worker at metadata too, sozero cycles complete. #108060 went one layer too shallow, unpinning count throttles the
mutation never reaches.
Fix: disable regular merges for the table (
max_bytes_to_merge_at_max_space_in_pool = 0) so theselector reaches mutation selection. Mutations are unaffected, reading
getMaxSourcePartBytesForMutationinstead. With merges off parts accumulate, soparts_to_delay_insert/parts_to_throw_insertare raised. Same approach as04652_mutate_part_ahead_of_table_metadata_version.sh.SYSTEM STOP MERGESwould not work eventable-scoped: it takes the
merges_blockerlock, whichReplicatedMergeTreeQueue::shouldExecuteLogEntryapplies toMUTATE_PARTtoo.No assertion is weakened and the guard is untouched, so this makes the promised race happen
rather than tolerating its absence. Mutation-side column resolution is exercised 5.7x more
(
MUTATE_PART4,958 -> 28,249); the merge-side path under concurrentADD/DROP COLUMNstayscovered by
01079_parallel_alter_add_drop_column_zookeeperand03144_..._on_steroids, whichkeep merges on and force them with
OPTIMIZE FINAL. Raising the timeout was rejected: thestarved mutation decelerated with no bound.
Validation, same box and load, only the test file differing: master fails 5/50 with the
signature above; with the fix 50/50 on debug and 50/50 on ASAN. p95 drops 77.5s to
32.7s, nothing reaches the 180s hard deadline, the settings verifiably applied
(0
MERGE_PARTS), noToo many parts.