Skip to content

Isolate the mutation in 03100_lwu_01_basics from merges/mutations pool contention - #118435

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix/03100-lwu-basics-mutation-pool-contention
Sep 6, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix/03100-lwu-basics-mutation-pool-contention

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

03100_lwu_01_basics timed out in ALTER TABLE t_shared APPLY PATCHES SETTINGS mutations_sync = 2 in the Fast test of #116885 (report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116885&sha=76f996abfd704d65e2eeb35a9cc4de47ac9cf0ba&name_0=PR&name_1=Fast%20test).

The server log shows the merge-selecting task refusing to assign the mutation because the server-global merges/mutations pool was occupied by concurrent tests:

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

The table had just been re-attached by the test (DETACH TABLE / ATTACH TABLE), and on attach merge_selecting_sleep_ms is initialised near max_merge_selecting_sleep_ms when the partition has few parts, so the next attempt came only after 60 s and the mutations_sync = 2 wait hit its 60 s limit (Failed to wait for mutation '0000000000', will recheck repeated until TIMEOUT_EXCEEDED).

Set number_of_free_entries_in_pool_to_execute_mutation = 0 on the table so its mutation does not depend on the pool occupancy of unrelated tests, as 02899_restore_parts_replicated_merge_tree already does for the same reason (#112090). The test's output does not depend on this setting.

Related: #116885
Related: #112090

Changelog category (leave one):

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

🤖 Generated with Claude Code


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

…ool contention

The test timed out in `ALTER TABLE t_shared APPLY PATCHES SETTINGS mutations_sync = 2`:
the merge-selecting task refused to assign the mutation because the server-global pool was
occupied by concurrent tests (`max_tasks_count (32) - occupied (25) < number_of_free_entries_in_pool_to_execute_mutation (8)`),
and since the table had just been re-attached, `merge_selecting_sleep_ms` started near
`max_merge_selecting_sleep_ms`, so the next attempt was scheduled only after 60000 ms and the
`mutations_sync = 2` wait hit its 60 s limit. Set
`number_of_free_entries_in_pool_to_execute_mutation = 0` on the table, as `02899_restore_parts_replicated_merge_tree`
already does for the same reason.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116885&sha=76f996abfd704d65e2eeb35a9cc4de47ac9cf0ba&name_0=PR&name_1=Fast%20test
PR: #116885

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9312d28]

Summary: ✅


AI Review

Summary

This PR stabilizes 03100_lwu_01_basics by setting number_of_free_entries_in_pool_to_execute_mutation = 0 on the ReplicatedMergeTree test table so ALTER TABLE ... APPLY PATCHES is not postponed by unrelated merges/mutations pool occupancy after ATTACH TABLE. I checked the current mutation-selection path and this setting removes the exact scheduler gate described in the PR without weakening the test's behavioral contract. I did not find a correctness, coverage, or metadata issue that warrants an inline finding.

Final Verdict

✅ No blocking findings.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Sep 6, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Sep 6, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 6, 2026
Merged via the queue into master with commit 80d4b44 Sep 6, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/03100-lwu-basics-mutation-pool-contention branch September 6, 2026 20:39
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 6, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Sep 15, 2026
… 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 (#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 #61902 and is deliberately not touched
here; this is the same test-side remedy already merged in #118435 and #112090
for the identical log signature.

Related: #120099

Co-Authored-By: Claude Opus 5 <[email protected]>
eliangidoni pushed a commit to eliangidoni/ClickHouse that referenced this pull request Oct 7, 2026
…ontention

`04612_mutation_pruning_exotic_predicates` was killed by the Fast test 60 s
cap in `Fast test (arm_darwin)` on ClickHouse#117272 and ClickHouse#115724. Each merge-selecting
run that finds nothing to do multiplies the table's poll interval, and the
test's back-to-back replicated mutations push it to
`max_merge_selecting_sleep_ms` (60 s) within a second. When concurrent tests
occupy the server-wide merges/mutations pool, the run that sees the next
mutation is refused by the `number_of_free_entries_in_pool_to_execute_mutation`
guard, returns `Limited` and keeps the saturated interval, so no MUTATE_PART
is created for 60 s and `mutations_sync = 2` waits past the cap. The same
stall shows up on Linux, where the 600 s stateless timeout hides it, and in
`04696_mutation_pruning_subcolumn_predicates` (41.6 s in an amd_debug run).

Setting the threshold to 0 on the two replicated tables makes the guard
always pass for them, as in ClickHouse#118435. The queries and references are
unchanged. The engine-level starvation is ClickHouse#61902.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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

comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). 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.

2 participants