Skip to content

Isolate the mutation in 04068_lwd_minmax_projection_recovery_rmt from merges/mutations pool contention - #120122

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:isolate-04068-lwd-minmax-rmt-mutation-pool
Sep 15, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:isolate-04068-lwd-minmax-rmt-mutation-pool

Conversation

@groeneai

@groeneai groeneai commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Isolate the lightweight delete in 04068_lwd_minmax_projection_recovery_rmt from merges/mutations pool contention, so it no longer wedges at the Fast test 60 second cap.

Description

04068_lwd_minmax_projection_recovery_rmt stops making progress and is killed by the Fast test 60 s per-test cap: 3 failures in 190,994 runs over 45 days, 0 of them on master. Two sit at the cap, 60.05 s and 60.10 s; the third is collateral (1.45 s, one of 31 failures in one Fast test job on an unrelated Keeper PR). In the job that surfaced it (#120099) it was the sole red of 15,103 rows. It is a stall, not a slow test: the OK maximum is 7.0 s over 25,331 Fast test runs and 14.5 s over 10,219 arm_darwin runs. The non-replicated sibling: 0 failures in 190,985 runs.

Root cause: the 12 single-row INSERTs produce 12 back-to-back merge-selecting iterations finding nothing mergeable, and each CannotSelect multiplies the poll interval up to max_merge_selecting_sleep_ms (60 s). The one iteration that then sees the new mutation is refused by the pool-headroom guard and returns AttemptStatus::Limited, which matches neither arm of the backoff epilogue, so the saturated interval is reused:

Number of queued mutations (0) is greater than max_replicated_mutations_in_queue (8) or there are not
enough free threads for mutations (max_tasks_count (32) - occupied (25) <
number_of_free_entries_in_pool_to_execute_mutation (8)), so won't select new parts to merge or mutate.
Scheduling next merge selecting task after 60000ms, current attempt status: Limited

No MUTATE_PART is created for 60 s, so lightweight_deletes_sync = 2 waits out max_execution_time.

number_of_free_entries_in_pool_to_execute_mutation = 0 makes the guard's comparison unconditionally true for this table, so the mutation is assigned on the first iteration that sees it. All four assertions and both synchronous waits are unchanged.

The engine-level starvation is open and maintainer-owned (#61902); the identical remedy for this identical log signature was merged in #118435 and in #112090, while my attempt to change the scheduling behaviour instead (#108916) was closed unmerged.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120099&sha=13008a61c4b5e2d5c60b9d726afa5ed75ae2a531&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29

Local reproduction: 2x2 over occupancy and this diff (click to expand)

Debug build, CI stateless configs (tests/config/install.sh ... --fast-test, so
max_execution_time is the lane's own 60 s), BackgroundMergesAndMutationsPoolSize = 32 as in CI.
The guard threshold was raised to 31 by a drop-in so that a few occupied slots stand in for CI's 25,
and helper-table merges held BackgroundMergesAndMutationsPoolTask at a stable 6 of 32.

Arm test file pool rc wall stdout vs .reference guard refusals MUTATE_PART
A pristine occupied, 6/32 159 60.64 s truncated after before_delete 19 0
B this diff occupied, 6/32 0 2.69 s byte-for-byte match 0 12
C this diff idle, default threshold 8 0 1.18 s byte-for-byte match 0 -
D pristine idle 0 1.29 s byte-for-byte match 0 -

A against B is the both-directions proof (same server, same binary, same occupancy, only this diff
differs); A against D shows the failure is occupancy-dependent rather than a broken test. Arm A's
exception is the CI one: Code: 159 ... elapsed 60084.481 ms, maximum: 60000.000 ms (TIMEOUT_EXCEEDED) on DELETE FROM t_lwd_proj WHERE id < 5, with 59 Failed to wait for mutation '0000000000', will recheck lines and no MUTATE_PART entry.

Stability: clickhouse-test --test-runs 50 --order random 04068_lwd_minmax_projection_recovery
covers both this test and its plain sibling: 100 passed, 0 failed. 02440_mutations_finalization
and 03716_mutations_parts_postpone_reasons_rmt, 10 runs each: 20 passed, 0 failed.


Workflow [PR]
Sync PR [sync-upstream/pr/120122]

Version info

  • Merged into: 26.9.1.1512 (included in 26.9 and later)

… merges/mutations pool contention

04068_lwd_minmax_projection_recovery_rmt stops making progress and is killed by
the Fast test 60 second per-test cap: 3 failures in 190,994 runs over 45 days,
none of them on master, and in the job that surfaced it (ClickHouse#120099) it was the sole
red of 15,103 rows. It is a stall rather than a slow test (the OK maximum is
7.0 s over 25,331 Fast test runs and 14.5 s over 10,219 arm_darwin runs, while
the failures sit at 60.05 and 60.10 s), and the non-replicated sibling of this
test has 0 failures in 190,985 runs.

The twelve single-row INSERTs each schedule the merge-selecting task, so twelve
iterations run back to back, find nothing mergeable and return
AttemptStatus::CannotSelect, which multiplies merge_selecting_sleep_ms up to
max_merge_selecting_sleep_ms (60 s). DELETE FROM then creates the mutation, and
the single iteration that sees it is refused by the pool-headroom guard in
CompactionStatistics::getMaxSourcePartBytesForMutation:

  max_tasks_count (32) - occupied (25) <
  number_of_free_entries_in_pool_to_execute_mutation (8)

so max_source_part_bytes_for_mutation is 0 and mergeSelectingTask returns
AttemptStatus::Limited. Limited matches neither arm of the backoff epilogue, so
the saturated 60 second interval is reused verbatim, no MUTATE_PART entry is
created, and lightweight_deletes_sync = 2 blocks until max_execution_time fires.
With the threshold at 0 the guard's comparison is unconditionally true for this
table, so the mutation is assigned on the first iteration that sees it, whatever
unrelated parallel tests are doing to the server-global pool. The non-replicated
sibling is immune because StorageMergeTree::mutate() calls
background_operations_assignee.trigger(), which shrinks its backoff instead of
leaving it saturated.

Reproduced as a 2x2 over pool occupancy and this diff, on one server and one
binary: the pristine file with an occupied pool fails with code 159 after
60.64 s; this diff under the same occupancy passes in 2.69 s with byte-for-byte
reference output; both files pass on an idle pool, which places the failure on
occupancy rather than on the test. 100 of 100 randomized runs of this test and
its plain sibling pass, as do 10 runs each of 02440_mutations_finalization and
03716_mutations_parts_postpone_reasons_rmt.

The engine-level starvation, where Limited reuses a saturated interval for every
Replicated table, is tracked upstream in ClickHouse#61902 and is deliberately not touched
here; this is the same test-side remedy already merged in ClickHouse#118435 and ClickHouse#112090
for the identical log signature.

Related: ClickHouse#120099

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings; bounded: 1 full pass +
1 fix round + 1 delta recheck), plus my own cold read of the diff before that pass. The independent
pass covered the changed test, its plain sibling, the mutation scheduling and execution callers,
setting validation and randomization, and the CI failure artifact.

# Sev Finding Verdict Evidence / action
1 💡 The draft PR body called the Limited reschedule block "untouched since 2023-05" AGREE, fixed before publication git log -L 4640,4660:src/Storages/StorageReplicatedMergeTree.cpp lists 6 commits after dbf08b25fb8f5, the most recent dc3d47d6899a0 (2026-01-20). The claim is gone from the body; only the parts I verified remain.
2 💡 The draft body listed 3 failures but characterised only the 2 that sit at the 60 s cap AGREE, fixed before publication The third (PR #117135, 2026-08-30) lasted 1.45 s and was 1 of 31 failures in that single Fast test job on an unrelated Keeper PR. The body now says so, which sharpens the evidence rather than softening it.
3 💡 04077_lwd_replicated_flag is a structural sibling (Replicated, DELETE FROM, lightweight_deletes_sync = 2) left unpinned DISAGREE The stall needs the poll interval already clamped at max_merge_selecting_sleep_ms before the mutation exists. Only this test's 12 single-row INSERTs into 12 partitions generate the back-to-back CannotSelect iterations that ratchet 5,000 ms to the 60,000 ms clamp (:4646 multiplies only on CannotSelect, :4649 clamps). 04077 does one INSERT into one partition, so its interval sits near the 5,000 ms floor and a refusal is retried about ten times inside max_execution_time; the interpolation that would seed a high interval is gated on LoadingStrictnessLevel::ATTACH <= mode (:599) and does not apply to a fresh CREATE TABLE. CIDB agrees: 188,846 OK, 0 FAIL, 45 days. Pinning it would be a speculative change to an unreproduced path.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal
per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Two harness observations from the failing job, recorded because they cost diagnosis time and are not
this test's problem: on arm_darwin the runner could not deliver the kill it had decided on
(Got Operation not permitted while sending SIGKILL to 90266, so the group is only reported as
"should be killed"), and on a timeout tests/clickhouse-test attaches stderr and the debug log but
not the partial .stdout, so the stalling query had to be recovered from the server log instead.
Neither is raised as work here.

Session id: cron:clickhouse-review-slot-9:20260915-052700

@clickhouse-gh clickhouse-gh Bot closed this Sep 15, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7086997]

Summary: ✅


AI Review

Summary

This PR hardens 04068_lwd_minmax_projection_recovery_rmt against unrelated merges/mutations pool contention by setting number_of_free_entries_in_pool_to_execute_mutation = 0 on the replicated test table, while leaving the projection-behavior assertions unchanged. I did not find a correctness or coverage regression in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 15, 2026
@groeneai
groeneai requested a review from Michicosun September 15, 2026 05:51
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 15, 2026
@PedroTadim PedroTadim self-assigned this Sep 15, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Sep 15, 2026
Merged via the queue into ClickHouse:master with commit 933221e Sep 15, 2026
176 of 348 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 15, 2026
@clickhouse-gh clickhouse-gh Bot added comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants