Skip to content

Make background merges and mutations observe cancellation in the S3 retry loop - #113939

Merged
CheSema merged 31 commits into
ClickHouse:masterfrom
groeneai:fix-background-mutation-cancellation-predicate
Nov 2, 2026
Merged

CheSema merged 31 commits into
ClickHouse:masterfrom
groeneai:fix-background-mutation-cancellation-predicate

Conversation

@groeneai

@groeneai groeneai commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed background merges and mutations ignoring cancellation while reading from an unreachable S3 endpoint. Such a merge or mutation kept retrying to its retry budget, so KILL MUTATION, SYSTEM STOP MERGES, SYSTEM STOP TTL MERGES and shutdown had no effect on it, and a following DROP TABLE waited for it, blocking further DROP/DETACH on that database.

Description

Related: #58479
Related: #66656

On 26.8.18.2, a mutation whose IN subquery reads an unreachable S3 endpoint is still in system.merges 60 s
after KILL MUTATION (S3ClientRetryStrategy: Attempt 26/501) and DROP TABLE ... SYNC blocks behind it, which
a stress-test hung check reported as a possible deadlock
(report).
A merge reading through an S3 disk hangs the same way under SYSTEM STOP MERGES, SYSTEM STOP TTL MERGES or
shutdown.

The S3 retry loop already checks ThreadStatus::isQueryCanceled, but a merge or mutation thread group answered
false. Master now installs merge and mutation predicates on the group, which this PR builds on:

  • MergeTask::prepare installs its predicate only at its end, and a thread copies the predicates when it attaches,
    so the reads prepare itself issues (statistics, marks) never see it. The merge predicate is now also installed
    before the task first runs.
  • After prepare, the merge predicate ignored SYSTEM STOP TTL MERGES for an assigned TTLRecompress merge. It
    now has the same TTL term as the earlier one.
  • The mutation predicate and the interactive-cancel callback did not persist an observed cancellation, so a
    STOP MERGES / START MERGES between two polls resurrected the read. Both now latch it, as the merge path does.
  • ReadBufferFromS3::processException reports a cancelled read as cancelled, not as the last S3 error.

Tests: 04826_kill_mutation_cancels_s3_read (mutations) and test_merge_cancel_s3_read (merges: STOP MERGES,
STOP TTL MERGES before and after prepare, shutdown, and a negative arm). On master eef0f17166d, 04826 fails its stop/start arm
and 5 of the 6 earlier integration arms fail; all pass here.


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

Version info

  • Merged into: 26.11.1.1110-master (included in 26.11 and later)

A mutation whose `IN` subquery reads an unreachable S3 endpoint ignored
`KILL MUTATION` and kept retrying the request to its budget. The subsequent
`DROP TABLE` then blocked in
`MergeTreeBackgroundExecutor::removeTasksCorrespondingToStorage` with
`DROP DATABASE` / `DETACH DATABASE` queued behind it, which a stress-test hung
check reports as a possible deadlock.

The S3 retry loop already checks cancellation before sleeping
(`Client::RetryStrategy::ShouldRetry`), and so do the redirect loop and
`HeadObject`. All of those checks were dead for background merges and mutations:
they resolve through `ThreadStatus::isQueryCanceled`, whose predicate is
installed by the `ThreadGroup` constructor and goes through the query context's
process-list element -- and nothing on the merge/mutate path ever sets one, so
the predicate answered constant `false`. `KILL MUTATION` records itself in
`MergeListElement::is_cancelled` instead, which the IO layer cannot see.

The interactive-cancel callback that `mutatePartToTemporaryPart` already
installs does not cover this: `PipelineExecutor::cancel` is cooperative and
cannot preempt a processor already inside `work()`, so a read parked in the
blocking retry loop never observes it. The hang is also reached while the
mutation's plan is still being built (materializing the `IN` set for
primary-key analysis), before the per-block checks around the row loop apply.

Install the predicate the mutation already builds --
`merges_blocker || MergeListElement::is_cancelled`, i.e. both storage shutdown
and `KILL MUTATION` -- on the mutation's thread group, so the existing
cancellation points become live. Both predicates are set: the boolean one for
`isQueryCanceled`, and a throwing one raising the same `ABORTED`
"Cancelled mutating parts" that `MutationContext::checkOperationIsNotCanceled`
uses, for `CurrentThread::checkIfNotCancelled`. They are stored verbatim so the
generic thread-group setter stays free of MergeTree error codes and message
text. This runs before the group's first attach, which is what makes it visible
to attaching threads: both mutation paths reach it from `prepare()`, while their
`ThreadGroupSwitcher` is still guarded by a not-yet-created merge-list entry.

`ReadBufferFromS3::processException` also has to fail fast on cancellation.
It recognised only three non-retryable cases and fell through to `return true`
for everything else, so it would have swallowed the cancellation raised inside
`S3::Client` and slept in its own retry loop -- relocating the sleep rather than
honouring the kill. Asking the thread rather than matching an error code mirrors
`Client::RetryStrategy::ShouldRetry`, covers every cancellation cause through
the one helper both of its retry loops share, and stays false for an ordinary
network error.

Measured on a dead endpoint with `KILL MUTATION`: before, the mutation was still
in `system.merges` after 300 s having made 64 further S3 attempts, and the
`ABORTED` throw never happened; after, it stops 4.5 s after the kill with one
further attempt. A foreground query on the same read was already cancelled in
under 5 s in both cases, which is what isolates the defect to the background
predicate.

Merges are not covered here: `mergePartsToTemporaryPart` is re-entered from
inside a running merge by projection sub-merges, so the same installation is not
safe there, and merges already consult their own cancellation predicate between
blocks.
… error

Covers the throwing half of the cancellation predicate: `Client::HeadObject`
reports a killed read through `CurrentThread::checkIfNotCancelled`, so with
only the boolean half installed the mutation still stops promptly but ends in a
misleading `S3_ERROR` instead of `ABORTED`.
…read too

`KILL MUTATION` sets only the merge-list entry's flag, so without this arm the
`merges_blocker` half of the predicate -- the storage-shutdown source -- is not
pinned by any assertion.
No behaviour change: 35 added source lines, 9 comment against 22 code, longest
consecutive comment block 3. The both-directions proof and the 50-run randomized
batch were re-run on the resulting binary.
`processException` returning false makes both callers reach a bare `throw;`, which
rethrows the exception that is still active -- the stale S3 or network one. So wherever
this function is the first frame to notice the kill, a killed mutation surfaces as
`S3_ERROR` instead of `ABORTED`: exactly the misreporting the `cancelled, not S3 error`
assertion of 04826 exists to forbid, and the contract the preceding commit describes.
It was also asymmetric with `Client::HeadObject`, which this branch claims to mirror and
which reports a killed read by throwing.

Calling `CurrentThread::checkIfNotCancelled` instead propagates the cancellation cause.
It is a no-op when no throwing predicate is installed, so every other caller of this
retry loop is unaffected and the explicit `CurrentThread::isInitialized` guard is no
longer needed; for a foreground query it raises `QUERY_WAS_CANCELLED`, which is what a
cancelled `SELECT` through this buffer already reported. Throwing here skips no cleanup:
`resetWorkingBuffer` and `impl.reset()` sit on the retry path, reached only when this
function returns true.

The reported hang does not reach this branch. It stalls in `HeadObject`, while
`StorageObjectStorageSource` is still resolving metadata, so no read buffer exists yet
and neither `nextImpl` nor `readBigAt` -- the only two callers -- has run. The branch is
therefore not pinned by the committed test, and four stub-endpoint shapes failed to
construct a mid-read failure to pin it with. It is still required: `ABORTED` matches none
of the three fail-fast conditions below it, so without it the loop sleeps between
attempts and the retry budget swallows the cancellation on any path that does drive a
read buffer, such as a body read failing after a successful GET.
…r starts

The arm waited for the mutation to appear in `system.merges` but never asserted that it
did. If the wait timed out, `SYSTEM STOP MERGES` cancelled nothing, the second poll found
`system.merges` already empty on its first iteration, and the arm printed its expected
line with the `merges_blocker` half of the predicate never exercised -- and that half is
the only thing the corresponding mutant reddens, so a silent pass here left it unpinned
too. Echoing the guard, as the first arm already does, turns that into a diff naming the
arm while keeping the remaining assertions visible.

Reaching the running state is not free, which is what made the silent pass reachable
rather than theoretical: a mutation is only scheduled while the pool has
`number_of_free_entries_in_pool_to_execute_mutation` free entries, which CI pins to 8,
and this arm queues its mutation while the first arm may still hold a slot. Pinning the
setting on both tables removes the dependence on what else the run has queued, and
`auto_statistics_types = ''` keeps the set from being built via the statistics estimation
path so the read under test stays the key-analysis build. Both siblings of this family --
04516 and 03644 -- pin the same pair for the same reasons, and the pin is per table
rather than a `no-random-settings` tag so the rest of the run stays randomized.

Verified by sabotage: with `SYSTEM STOP MERGES` moved ahead of the `ALTER` so the
mutation can never be scheduled, the amended test fails on the new line
(`stop merges: mutation started: 1` against an observed 0) while the previous shape of
the same sabotaged test still passed.
…t the read

The predicate this branch installs is polled by two independent consumers: the
interactive-cancel callback, from the `CompletedPipelineExecutor` loop at
`interactive_delay` cadence, and the S3 read itself, which rechecks only between retry
attempts -- measured at a steady 5 s apart once the backoff saturates. Its `merges_blocker`
half is a live read of blocker state, so a blocker released between the callback observing
it and the read's next check leaves the read seeing `false` again, and the uninterruptible
retry loop this branch exists to interrupt is back.

The window is not exotic. Every scoped `ActionLock` on `merges_blocker` releases on scope
exit, and ordinary DDL takes one: TRUNCATE, DROP PART, DROP/DETACH PARTITION, REPLACE
PARTITION, MOVE PARTITION TO TABLE, a forced `outdatePart`, the DROP DATABASE pre-cancel
and the SystemLog flush. Sharpest of all, `stopMergesAndWait` throws on its
`DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC` wait, so an uninterruptible read makes that wait
give up and release the blocker while the read carries on -- the release is a consequence
of the very hang being fixed.

The merge path already solves this and says why: both `MergeTask::GlobalRuntimeContext::
isCancelled` and its per-block lambda latch into `MergeListElement::is_cancelled` under a
comment naming rapid STOP/START toggling. This mirrors them verbatim in structure and
ordering. Latching is safe because the merge-list entry is per attempt -- created in
`prepare`, erased by `~BackgroundProcessListEntry` -- so a latched value cannot leak into a
later retry of the same mutation, and no site in the tree ever stores `false`.

Measured on two servers whose build ids were asserted against the binaries: with the latch
the in-flight attempt reports `Cancelled mutating parts` 4.06-4.39 s after the toggle,
having issued one further S3 attempt; without it the same toggle is not reported at all
within 120 s, across 25 further attempts.

The new arm's oracle is the attempt reporting cancellation rather than the task leaving
`system.merges`: a released blocker leaves the mutation schedulable, so the entry
legitimately reappears (observed elapsed growing 0.2 s to 30.5 s across reschedules) and
the existing arm's oracle is unsatisfiable for this shape.
Issuing the STOP and the START back to back leaves a window shorter than any poll interval,
so neither the interactive-cancel callback nor the read observes the cancelled blocker and
there is nothing to latch: the arm then fails on a correct binary. Measured with the window
length as the only variable, six runs per form on one server whose build id was asserted:
back to back 0/6, a 0.2 s hold 6/6, a 0.5 s hold 6/6. The committed 0.5 s keeps margin over
the 100 ms callback cadence.

The hold does not weaken what the arm tests. The property under test is that the blocker is
released again while the read is still retrying, and it still is: the release lands inside
the read's own inter-attempt gap, measured at a steady 5 s once the backoff saturates. The
arm still fails 6/6 without the latch and passes 20/20 with it.
`various_checks.sh` requires `SYSTEM FLUSH LOGS <log_name>` over the global form, and the new test
used the global one, so `Style check` would have failed on it. The flush exists only to make
`system.part_log` readable by the assertion two lines below it, which is the only system log table
the test queries -- `system.merges` and `system.mutations` are live views, not logs -- so `part_log`
is the whole of what it needs.

Behaviour-preserving, and the assertion stays armed: with the flush removed entirely the arm reddens
`cancelled, not S3 error` from 1 to empty, so the flush is load-bearing rather than decorative, and
with it scoped the test is 6/6 OK. `various_checks.sh` output goes from the one offending line to
empty; reinstating the global form makes the rule fire again, so the check discriminates.
@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent model reviewed this change against the repository's review guidelines, and I
adjudicated its findings against the code and the measurements recorded for this branch. Verdicts
below; everything raised was either fixed or is answered with evidence.

❌ Blockers (fixed)

merges_blocker cancellation was not sticky, so a transient release could resurrect the
uninterruptible read.
The predicate this change installs on the mutation's thread group is read
by two independent consumers: the interactive-cancel callback, from the
CompletedPipelineExecutor loop at interactive_delay cadence, and the S3 thread's own
cancellation checks. Its merges_blocker half was a live read, so a blocker released between the
callback observing cancellation and the S3 thread's next check left that thread retrying a read
whose pipeline was already cancelled.

The window is not limited to a hand-issued SYSTEM STOP/START MERGES pair: transient scoped
merge blocks are taken by TRUNCATE, DROP PART, DROP/DETACH PARTITION,
REPLACE/ATTACH PARTITION FROM, MOVE PARTITION TO TABLE and the DROP DATABASE pre-cancel,
each releasing on scope exit. Sharpest of all, stopMergesAndWait waits for running merges with a
lock-acquire timeout that throws, so an uninterruptible S3 read makes that wait give up and
release the blocker while the read carries on: the release is a consequence of the very hang this
change fixes.

Fixed by persisting a detected cancellation into MergeListElement::is_cancelled inside the
existing predicate, which is what the sibling merge path already does for exactly this reason
(MergeTask::GlobalRuntimeContext::isCancelled, whose comment names rapid
SYSTEM STOP/START MERGES toggling). The flag is atomic and one-way, and the merge-list entry is
created per mutation attempt and destroyed with it, so a persisted value cannot leak into a later
retry. A test arm covers a transient stop/start against the dead endpoint.

⚠️ Majors (fixed in earlier rounds of this review)

A cancelled read was reported as the last S3 error rather than as a cancellation. The retry
helper returned false on cancellation, and both callers then rethrow the exception that is still
active, the stale S3 one. So wherever that helper was the first frame to notice the kill, a
killed mutation surfaced as S3_ERROR instead of ABORTED, which is what this change's own
assertion exists to forbid, and it was asymmetric with Client::HeadObject, which reports a
killed read by throwing. It now propagates the cancellation cause; a foreground query is
unaffected, and the recorded control value for a cancelled SELECT through this buffer did not
move.

The stop-merges test arm could pass without exercising the second cancellation source. It
waited for the mutation to appear in system.merges but never asserted that it had, so a
mutation that was never scheduled produced the arm's expected line with the merges_blocker half
of the predicate untested, and that half is the only thing the corresponding mutant reddens. The
arm now asserts the running state, and both tables pin the mutation-scheduling and statistics
settings the two sibling tests in this family already pin, so the arm no longer depends on what
else the run has queued. Verified by sabotage: with the stop moved ahead of the mutation, the
amended test fails on the new assertion while the previous shape still passed.

⚠️ Majors (answered with evidence, not changed)

"The transient stop/start arm can pass without the new persistence, if the S3 thread happens to
check while merges are still stopped."
The mechanism is right and worth stating: the two consumers
of the predicate are unordered, so if the S3 thread's own check falls inside the interval during
which merges are stopped, it observes the live block and reports the cancellation without needing the
persisted flag at all. The conclusion that the arm therefore cannot discriminate does not follow.
Reverting the persistence and nothing else, with both cancellation sources still installed, reddens
that arm in six of six runs, each on a binary whose build id was checked against the running server,
and the diff in all six is that one line while the six older assertions stay green. The escape is
also the minority ordering rather than the usual one: once the S3 backoff saturates, the read
rechecks about every five seconds against a half-second stop, so it lands inside the window roughly
one run in ten, which is what six of six already reflects.

The suggested remedy, a seam that releases the block after the callback has seen it but before the
S3 thread looks, is not available to a functional test: the S3 client has no failure-injection points
at either check, and the read cannot be slowed or hurried from SQL either, since a mutation runs on a
background context and the object-storage layer applies per-query S3 settings only for non-background
contexts. Satisfying it would mean adding injection points to the S3 client purely to order a test
arm that already fails on the unpatched binary every time, so the arm is kept as it is.

💡 Noted, not changed

The cancellation fail-fast in the read-retry helper is not covered by the new test. The
reported hang stalls while resolving object metadata, before any read buffer exists, so neither
caller of that helper runs; four stub-endpoint shapes failed to construct a mid-read failure to
pin it with. It is still required: the cancellation code matches none of the fail-fast conditions
below it, so without it the loop sleeps between attempts and the retry budget swallows the
cancellation on any path that does drive a read buffer, such as a body read failing after a
successful GET. Kept, with the gap stated in the commit message rather than papered over.

Merges are deliberately not covered. mergePartsToTemporaryPart is re-entered from inside a
running merge by projection sub-merges, so installing the predicate there is not safe in the same
place, and merges already consult their own latched predicate between blocks.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation (a-i)
# Check Answer
a Deterministic repro? Yes. ALTER TABLE t_mut DELETE WHERE id IN (SELECT * FROM s3('http://localhost:19999/dummy.parquet','NOSIGN','One')) SETTINGS mutations_sync = 0 then KILL MUTATION, with nothing listening on 19999. Before the fix the task is still in system.merges at 300 s; after, it is gone in 4.5 s. The committed test is OK on the fixed binary and FAIL on the unmodified one.
b Root cause explained? Yes. ThreadStatus::isQueryCanceled reads a predicate the ThreadGroup constructor routes through the query context's process-list element, and nothing on the merge/mutate path sets one, so it answered constant false and every IO-layer cancellation check was dead for background tasks. KILL MUTATION records itself in MergeListElement::is_cancelled, which the IO layer cannot see.
c Fix matches the root cause? Yes. The predicate the mutation already builds is installed on the group the IO layer polls. No widened bound, no no-random-* tag, no dataset reduction, and no guard bolted onto the failing call site.
d Test intent preserved / new tests added? New stateless test with eight assertions covering three cancellation shapes -- KILL MUTATION, a held SYSTEM STOP MERGES, and a stop released again while the read is still retrying -- plus a check that the mutation stops because it was cancelled and, for each shape, that its mutation really started before the cancellation was issued. No existing test weakened: 20 tests of the mutation/cancellation family were run on both binaries and every verdict and failure reason is identical.
e Both directions demonstrated? Yes, with each binary's Build ID asserted equal to SELECT lower(buildId()) before any verdict. Unmodified: mutation still running at 300 s, 64 further S3 attempts after the kill, ABORTED throw absent. Fixed: gone in 4.5 s, one further attempt, throw present.
f General across code paths? git grep -n mutatePartToTemporaryPart gives four lines: two call sites (MutatePlainMergeTreeTask.cpp:80, MutateFromLogEntryTask.cpp:252) plus the declaration and definition, so both the plain and the replicated mutation path are covered by the single change. Fixing the predicate rather than the call site also revives other cancellation checks that were dead for the same reason: the three in S3::Client on this branch, and the two in ConnectionEstablisher that master has added since this branch's base.
g Generalizes across inputs? The predicate carries no types, values or settings, so there is no input matrix to sweep. Both cancellation sources are covered and each has its own assertion; a control confirms an ordinary network error with no cancellation still retries to its budget on both binaries -- observed in one 1500 s window at 907 client-level attempts and still going, against the one further attempt a cancelled read makes. The one dimension that did need sweeping is how long a cancellation stays visible: because two consumers poll the predicate independently, a detected cancellation is persisted, and the third assertion pins that a stop released again mid-read is still honoured.
h Backward compatible? Yes. No setting, no default change, no serialization format, no on-disk state and no protocol change, so no SettingsChangesHistory.cpp entry is owed. The only behaviour change is that a killed background mutation stops, which is what KILL MUTATION already promises.
i Invariants and contracts preserved? The setter runs before the group's first attach, which is the contract behind the one-time shared_data copy in attachToGroupImpl; both mutation paths reach it from prepare() while their ThreadGroupSwitcher is still guarded by a not-yet-created merge-list entry. It takes mutex, matching shared_data's TSA_GUARDED_BY. No runtime zero-attached-threads assertion was added, since projection sub-merges legitimately re-enter the merge entry point after attach. The new exception is the ABORTED "Cancelled mutating parts" the mutation path already throws; measured across every fixed-binary run: zero broken-part reports, zero reportBroken, zero <Fatal>. A mutation on a table with a projection, and a subsequent OPTIMIZE FINAL, both give exact row counts with no assertion or abort.

Validation also included 20 of 20 plain and 50 of 50 randomized runs of the new test, and a mutation
matrix in which reverting the change, installing only the boolean predicate, dropping either term of
the predicate, and reverting only the persistence of a detected cancellation each reddens a named
assertion -- the last of these reddening the third shape and nothing else -- with the tree rebuilding
to a byte-identical Build ID afterwards. Reverting the ReadBufferFromS3 fail-fast alone reddens
nothing, because the reported hang stalls in HeadObject before any read buffer exists; the commit
that adds it records why it is nevertheless required and that the committed test does not pin it.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alesapin @CheSema, could you review this? A background mutation's thread group never gets a cancellation predicate, because the constructor routes it through a process-list element the merge/mutate path never sets, so isQueryCanceled is constant false and every existing IO-layer cancellation check is dead for it: a mutation whose IN subquery reads a dead S3 endpoint ignores KILL MUTATION and holds up the following DROP TABLE. This installs the predicate the mutation already builds on its own thread group, so those checks become live.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2ff5b11]

Summary: ✅


AI Review

Summary

The PR makes background merges and mutations observe cancellation during S3 retries, including TTL cancellation and transient merge blockers. One previously reported test-isolation issue remains in the current code; no new inline findings were identified.

Missing context / blind spots
  • ⚠️ Functional, integration, and bugfix-validation jobs for 2ff5b11317772306350ae446f8b4ba4a73bbf806 are still pending. Their completed results are needed to validate this head; tests were not rerun locally. CI report.
Findings

⚠️ Majors

  • tests/integration/test_merge_cancel_s3_read/test.py:182 — Failed assertions leave shared-server work running. Both test_stop_merges_cancels_s3_read and test_stop_ttl_merges_does_not_cancel_regular_merge perform cleanup only after their assertions. A failure can leave a retrying merge or OPTIMIZE alive on the module-scoped server; subsequent cases then count its requests through the server-global ATTEMPTS_QUERY, causing misleading secondary failures. Put mock reset, outstanding-request cleanup, and table cleanup in finally, as the later cases do. This is the existing unresolved finding; no duplicate comment was posted.
Final Verdict

Status: ⚠️ Request changes. Make the first two integration tests clean up on assertion failure, and verify the pending regression jobs.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 8, 2026
@PedroTadim PedroTadim self-assigned this Aug 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 2ff5b1131 with master 7fc4e86ed (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

11 object files changed (+40.70 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeDataMergerMutator.cpp.o 540.46 KiB 580.76 KiB +40.30 KiB (+7.46%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

255 translation units recompiled, 2898 s compile time in total, 255 of them have a recent master baseline.

Job report

groeneai and others added 6 commits August 9, 2026 01:18
The same defect the mutation half of this PR fixes applies to background merges, which
build their ThreadGroup identically and reach ReadBufferFromS3 through the disk: the
group's cancellation predicates resolve through a process-list element a merge context
does not have, so they answer constant false and the retry loop the IO layer polls never
observes the cancellation. The merge's own checks cannot substitute, because all of them
are polled between blocks and are unreachable from inside a blocking read. A merge stuck
that way retries to its budget while holding the table, which is the hung check reported
on the mutation path.

Installed only for root merges. A projection sub-merge re-enters
mergePartsToTemporaryPart from inside a running merge whose group is already attached, and
an attach copies shared_data once, so writing predicates there would not reach its threads;
its parent's predicate covers the operation. The two root callers are distinguished by
mergePartsToTemporaryPart's own projection_merge_list_element parameter.

The background discriminator is read off the merge list entry's own thread group rather
than off the context argument, and this is load-bearing rather than stylistic. The
replicated caller builds a per-task context but passes the storage's context to this
function, and that is the global context, on which isBackgroundContext() is false; keying
on the argument would have covered plain merges and silently skipped replicated ones.
Reverting just that choice reddens the replicated test arm and leaves the plain one green.
For the same reason merges get only the thread-group predicate and no interactive-cancel
callback, which would write per-merge state onto a context the whole storage shares. A
failed lock() on that weak context throws instead of skipping: both root callers hold the
context as a strong member for the whole merge, so expiry is a violated invariant, and
skipping would recreate this very defect invisibly.

ttl_merges_blocker is deliberately not a source. It is state-aware on the merge path: an
assigned TTL merge aborts, but a regular merge with expired values only stops removing them
and continues. Folding it into a thread-group predicate would abort ordinary merges that
today complete, so this covers SYSTEM STOP MERGES and shutdown, not SYSTEM STOP TTL MERGES.
A test arm pins that.

optimizeDryRun is excluded by the background condition. It runs its task via executeHere
under the caller's thread group, so its entry group is never attached and its cancellation
is already the user query's.

The integration test needed a new immediate-failure GET injector in broken_s3.py. The
existing slow_get sleeps inside the request while the predicate is polled between retries,
so it would block a fixed and an unfixed server equally and prove nothing.
The merge-side predicate keyed only on merges_blocker, so an assigned TTL merge
parked in the S3 retry loop observed no cancellation source at all: for that
merge class ttl_merges_blocker is the only trigger, and its two check points
sit either before the read starts (MergeTask.cpp:563, in prepare()) or after
the merging executor has been drained (:1777). SYSTEM STOP TTL MERGES issued
in between therefore reached nothing, which is the same defect this branch
fixes for merges_blocker.

The condition is guarded by isTTLMergeType because the blocker is state-aware
on the merge path: for a regular merge it only disables opportunistic TTL
removal (:645, :1777, both keyed on need_remove_expired_values), so an
unguarded condition would abort merges that are supposed to complete.
isTTLMergeType is true only for TTLDelete/TTLRecompress/TTLDrop, and an
explicit OPTIMIZE selects MergeType::Regular, so those are unaffected.

is_ttl_merge is captured by value rather than computed in the lambda:
future_part is moved into the MergeTask below, so capturing it would dangle.

The mutation side is deliberately left alone -- a mutation's future part is
always MergeType::Regular, so the condition would be dead code there.
wait_for evaluates its predicate before the first sleep, and `settled` was
sampled immediately before the call, so `attempts - settled <= 2` was satisfied
on the very first sample whenever fewer than three requests landed in the
intervening milliseconds. The arm's own earlier guard only requires 20 attempts
over a 60 s window, so the request rate is low and that first sample passed
essentially always: the intended 15 s observation never elapsed.

Replaced with an explicit loop that sleeps first and requires every sample
across the window to hold, so a pass cannot be granted before the window has
been observed. The bound is unchanged. The failure message now carries the
observed count, which is what distinguishes a marginal overshoot from a read
that never stopped.

Scored by neutralising oracle (a) -- it short-circuits first, so (b) is
otherwise never reached on a failing build -- and reverting the merge-side
predicate install: (b) then fails on its own assertion, 42 - 39 <= 2, proving
it is load-bearing independently of (a).
The arm exists to kill one mutant: dropping the isTTLMergeType guard from the
merge-side predicate, which would abort a regular merge under SYSTEM STOP TTL
MERGES. It could not do that. The table used the default local disk and no S3
failure was injected, so the merge never entered a blocking read and never
polled the thread-group predicate -- the arm stayed green on exactly the code it
was supposed to reject.

It now uses the broken_s3 policy with a slow_down injection, like the sibling
arm, so the merge is parked in the retry loop polling the predicate, and drops
the caches so the read really goes to the mock. OPTIMIZE is issued through
get_query_request because on a plain table it runs the merge inline.

The liveness signal is our own OPTIMIZE still being in system.processes rather
than a row in system.merges: the mutant aborts the merge on its first poll, so
every "is it there yet" wait times out, and system.merges cannot distinguish
aborted from not-started-yet -- the arm then failed on a vacuity guard and read
as a broken harness rather than as a caught bug. The server log cannot be used
either, since it is shared with the sibling arm, which cancels merges by design.
The check runs inside every wait loop, so an abort fails immediately with the
right message wherever it happens.

optimize_throw_if_noop is off because with alter_sync = 0 a background merge may
claim the parts first, and that noop is not what the arm measures; a drain wait
was added before the final part count for the same reason.

Verified by mutation: with the guard dropped the arm fails on
"SYSTEM STOP TTL MERGES aborted a regular merge" (server log confirms the
regular merge really is aborted), and passes on the guarded form.
…ired values

MergeTask has two ttl_merges_blocker cancellation conditions, not one. The IO
predicate mirrored only the first (an assigned TTL merge type). The second is
phase-dependent: a regular merge whose need_remove_expired_values survived the
check in prepare() treats a later block as cancellation, so an explicit OPTIMIZE
removing expired rows is cancellable by SYSTEM STOP TTL MERGES. That state is
computed on the first executeStep, i.e. after the predicate is installed and
after the group's first attach, and an attach copies shared_data into local_data
exactly once, so a later re-install would never reach the merge's threads.

Publish the settled value on MergeListElement, the object both sides already
hold, exactly as is_cancelled is already shared. It must be the post-downgrade
value: publishing the pre-downgrade one would abort a merge that legitimately
continues with removal disabled, which is what the existing regular-merge arm
pins.

The mutation side is deliberately left alone: a mutation's future part is always
MergeType::Regular and a mutation never runs MergeTask::prepare(), so both terms
would be permanently false there.

Co-Authored-By: Claude Fable 5 <[email protected]>
Every previous arm passed with the whole TTL term deleted: the headline arms use
SYSTEM STOP MERGES, and the TTL arm proves only that cancellation is not
over-broad. Add one arm per positive branch, each asserting the two oracles the
headline arm uses.

The assigned-merge arm has to be a recompression merge. A TTLDelete or TTLDrop
merge is selected by part_min_ttl <= current_time, which is the same condition
that sets need_remove_expired_values, so the sibling entry-flag term already
covers those and an arm built on them stays green with the isTTLMergeType term
deleted (measured). A recompression TTL is recorded with
update_part_min_max_ttls = false, so it never feeds part_min_ttl and is the only
assigned TTL merge the removal state does not shadow.

Both arms use half-expired parts. Fully-expired ones are assigned TTLDrop, which
skips creating the read pipeline altogether and so never reaches S3.

The regular-merge arm sets max_number_of_merges_with_ttl_in_pool = 0 so the
assignee cannot claim its parts as a TTL merge before OPTIMIZE gets them, which
would silently make it a duplicate of the sibling arm.

Both arms drop their table through SYSTEM STOP MERGES in a finally block.
DiskS3ReadRequestsCount is server-global, so a merge left retrying by a failed
arm inflates the next arm's request-plateau count once its fixture resets the
mock.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai groeneai changed the title Make KILL MUTATION observe cancellation in the S3 retry loop Make background merges and mutations observe cancellation in the S3 retry loop Aug 9, 2026
@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent model reviewed this change against the repository's review guidelines over five
rounds; the final round returned no findings. Everything raised earlier was either fixed or is
answered with evidence.

❌ Blockers (fixed)

SYSTEM STOP TTL MERGES reached only one of the two TTL cancellation conditions. MergeTask
treats a TTL block as cancellation both for an assigned TTL merge and for a regular merge whose
need_remove_expired_values survived the check in prepare(). The thread-group predicate froze
only the first, so a regular merge that was actually removing expired values stayed stuck in the S3
retry loop, where the merge's own checks (between blocks, and post-drain) never run. Fixed by
publishing the settled removal state through MergeListElement, the object both sides already
share, stored after the blocker downgrade so the IO predicate cancels exactly when MergeTask's own
condition would. Publishing the pre-downgrade value would instead abort a merge that legitimately
continues with removal disabled; a mutant moving the store earlier reddens the negative control arm.

The merges_blocker half was not sticky. Two consumers poll the predicate independently, so a
blocker released in between could resurrect a read whose pipeline was already cancelled. Not
hypothetical: TRUNCATE, DROP PART, DROP/DETACH/REPLACE PARTITION and
MOVE PARTITION TO TABLE all take scoped blocks, and stopMergesAndWait gives up on its
lock-acquire timeout precisely because the read is uninterruptible. Fixed by latching into
MergeListElement::is_cancelled, as the sibling merge path already does for this reason.

⚠️ Majors (fixed)

Both positive TTL branches were unpinned. Each now has its own witness, and each mutant reddens
exactly one arm while the other four stay green. Only a recompression TTL merge can witness the
assigned-type term: a TTLDelete/TTLDrop merge is selected by part_min_ttl <= now, the same
condition that sets need_remove_expired_values, so the entry-flag term already covers those and an
arm built on them passes even with the term deleted (measured, not assumed).

A cancelled read was reported as the last S3 error, not as a cancellation. The retry helper
returned false on cancellation and its callers rethrew the still-active stale S3 exception, so a
killed mutation surfaced as S3_ERROR instead of ABORTED, asymmetric with Client::HeadObject.
It now propagates the cancellation cause.

PR metadata. Title, changelog entry and description still described a mutation-only fix after the
change grew to cover merges and both TTL branches; corrected, and the linked issues moved out of the
template's HTML comment so they render.

💡 Noted, not blocking

The processException fail-fast is not covered by a test arm: this defect stalls while resolving
object metadata, before any read buffer exists, so neither caller of that helper runs, and four
stub-endpoint shapes failed to construct a mid-read failure. It is still required, since ABORTED
matches none of the fail-fast conditions below it and the loop would otherwise sleep out the retry
budget on any path that does drive a read buffer.

Latching also arms the throwing predicate for the rest of the task, and cleanup runs while still
attached to the same thread group, so on an object-storage disk the post-cancellation temp-part
delete can now raise ABORTED at the pre-existing check in Client::doRequest.
IMergeTreeDataPart::removeIfNeeded catches everything, so the noexcept cancel is safe and no
invariant breaks; the only effect is that a cancelled merge's temp directory may be reaped by
temporary_directories_lifetime rather than immediately, which is the fallback the comment there
already describes.

@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation (a-i) for the second TTL cancellation condition

Round 4's table covered SYSTEM STOP TTL MERGES as a cancellation source for an assigned TTL
merge. That was only half of it: MergeTask has two TTL cancellation conditions, and the
second one -- a regular merge that has settled on removing expired values (MergeTask.cpp:1139,
need_remove && ttl_merges_blocker->isCancelled()) -- was still unreachable from inside a blocking
read. This round carries that phase-dependent state into the IO predicate through
MergeListElement, and pins both positive branches by test.

Shipping binary b4cddbcf516eaa7c50007dbfc09d114f7eada6ab. Mutants
6febd58e2c0c99445d399ddb31d14aadd0eb1436 (assigned-type term dropped),
e5cc794d196378c09c153a60ec1aac0efd4ef81c (removal-state term dropped) and
3811fcb8ff45b6ff7351e669905fe8688c1d7aa7 (state published before the downgrade). Every server's
Build ID was asserted equal to SELECT lower(buildId()) before any verdict was taken.

# Check Answer
a Deterministic repro? Yes, on demand, and structural rather than timing-dependent. need_remove_expired_values is settled in prepare(); from then on the only consumer is ctx->is_cancelled, polled between blocks (:1703) and again after the executor has drained (:1777). A SYSTEM STOP TTL MERGES issued while a block's read is parked in the S3 retry loop therefore reaches no check point -- byte-for-byte the shape of the merges_blocker gap this PR exists to fix.
b Root cause explained? One missing source on an otherwise correct mechanism. Round 4 froze isTTLMergeType(merge_type) at install time, which covers only the first of the two conditions. The second depends on state computed later, on the first executeStep, i.e. after the install site and after the group's first attach -- and attachToGroupImpl copies shared_data into local_data exactly once (ThreadStatusExt.cpp:397), so re-installing the predicate later would never reach the merge's threads.
c Fix matches the root cause? Yes: the settled value is published through the object both sides already hold, exactly as is_cancelled already is -- one std::atomic<bool> on MergeListElement, stored once at the single settling point in prepare(), read in the predicate. No new mechanism, no guard at the failing call site. It is the post-downgrade value, so a merge that legitimately continues with removal disabled is still not cancellable.
d Test intent preserved / new tests added? Two new arms, one per positive branch, both asserting the headline arm's two oracles. The pre-existing regular-merge control arm is unchanged in substance and is now the target of a dedicated mutant. No assertion relaxed, no bound widened, no dataset shrunk. Stateless 04826 untouched and 3 of 3 green on the shipping binary.
e Both directions demonstrated? Yes, by mutation, each observed rather than assumed. Dropping the assigned-type term reddens only the recompression arm; dropping the removal-state term reddens only the regular-merge arm; publishing the state before the downgrade reddens only the control arm (SYSTEM STOP TTL MERGES aborted a regular merge). Each mutant leaves the other four arms green, so the three arms are independent witnesses rather than one oracle firing three times. Correct code: 5 passed, 3 consecutive runs, plus the shipping binary.
f General across code paths? Both of MergeTask's TTL conditions are now mirrored, and the merge side remains the only carrier. A mutation's future part is always MergeType::Regular and a mutation never runs MergeTask::prepare(), so both terms would be permanently false there -- dead plumbing, deliberately not added. Projection sub-merges are still covered by the enclosing merge's predicate, and optimizeDryRun is still excluded via isBackgroundContext().
g Generalizes across inputs? The dimension is merge class x removal state, and all four cells are accounted for. TTLRecompress: assigned but not removing -- a recompression TTL is recorded with update_part_min_max_ttls = false (MergeTreeDataWriter.cpp:997), so it never feeds part_min_ttl and the removal flag stays false; this is the only witness for the assigned-type term, and the arm uses it. Regular + removing: the new arm. Regular + removal-disabled-up-front: the control arm. TTLDelete/TTLDrop: selected by part_min_ttl <= now, which is the same condition that sets the removal flag, so the flag already covers them -- measured, not assumed (an arm built on TTLDelete stayed green under the assigned-type mutant).
h Backward compatible? Yes. No setting, default, format, on-disk state or protocol, so no SettingsChangesHistory.cpp entry is owed. The atomic is deliberately not surfaced in MergeInfo/system.merges, so that schema is untouched. The exception raised is the ABORTED this path already raises.
i Invariants and contracts preserved? The atomic is written once, before any observer can see the merge doing IO, and read relaxed next to the existing relaxed latch; the latch order (entry flag first, then blockers) is unchanged, so a blocker toggled off and on mid-read still cannot resurrect a cancelled read. false is the safe direction -- it is the pre-existing behaviour -- so no ordering subtlety can turn into a spurious abort. is_ttl_merge stays a by-value bool because future_part is moved into the MergeTask a few lines below.

Two fixture facts worth recording, since either would otherwise ship a green-but-blind arm: a
TTLDrop merge skips creating the read pipeline altogether (MergeTask.cpp:1044-1051) and so
cannot hang on S3, which is why both arms use half-expired parts; and
system.merges.merge_type is magic_enum::enum_name(MergeType), i.e.
TTLDelete/TTLRecompress/Regular -- the 'TTL_DELETE' spelling in
test_concurrent_ttl_merges never matches, unnoticed there because every comparison in that file
is == 0 or <= 2.

groeneai and others added 2 commits August 9, 2026 12:17
The Style check requires an __init__.py in every tests/integration/test_*
directory (ci/jobs/scripts/check_style/various_checks.sh), to avoid pytest
"import file mismatch" between same-named modules. Style is a gating job, so
its failure dropped the other 155 checks on this PR.

Co-Authored-By: Claude Fable 5 <[email protected]>
The oracles compare DiskS3ReadRequestsCount, a server-global ProfileEvent
incremented for every object-storage disk (ObjectStorageFactory builds each one
with for_disk_s3 = true). In the `db disk` integration jobs
CLICKHOUSE_USE_DATABASE_DISK=1 makes cluster.py attach a second live S3 disk for
database metadata, so its background traffic lands in the same counter the test
reads.

That is what broke test_stop_merges_cancels_s3_read[False] in
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 3/6)`: the merge was
cancelled correctly (the server log shows ABORTED, and oracle (a) passed), but 5
metadata requests arrived during the 15 s settle window and tripped the `<= 2`
plateau bound. All 5 were reads of the root-db-disk bucket, issued 0.4 ms before
the failing sample; broken_s3 contributed none.

The tolerance is left alone deliberately: raising it would weaken the assertion
and mask a genuine non-cancellation, whereas removing the foreign signal source
keeps the bound as tight as it was. Same defect and same remedy as
test_profile_events_s3 and test_backup_restore_s3; 68 integration tests already
opt out this way. One module-scoped fixture serves the whole file, so every
counter-based oracle in it is covered.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e5d638b

That head carried 57 check-runs: 40 success, 7 skipped, 2 failure, and 8 cancelled when the commit
below superseded it, plus the CH Inc sync commit status. Both failures have an owner.

⚠️ This also corrects my previous ledger (#113939 (comment)),
which recorded the asan_ubsan miss as "fixed in this PR @ e5d638b". That claim was wrong: the fix
on that head did clear the miss from asan_ubsan, debug and binary (50 of 50 green each), but it made
tsan and msan fail in every run.

Check / test Reason Owner / fixing PR
Stateless tests (amd_tsan, flaky check) / 04826_kill_mutation_cancels_s3_read 19 of 19 runs, leg aborted; the reddened cell is the arm's premise, toggle: mutation started, not its oracle PR-caused (my own test) -> fixed in this PR @ 832c165
Stateless tests (amd_msan, flaky check) / 04826_kill_mutation_cancels_s3_read 11 of 11 runs, leg aborted, same cell PR-caused (my own test) -> fixed in this PR @ 832c165
CH Inc sync - CH Inc sync (private, not actionable by me)

Root cause, measured rather than inferred. The flaky check sets its worker count to nproc-1, 18 on that
runner, and every worker runs this same test, so they share one server's background mutation slots. From
the failing job's own part_log.tsv, the server never had more than 22 MutatePart tasks in flight at
once, about 1.2 per worker, and 17 of its 22 runs never got three of their own t_toggle mutations to
run at all. The previous round had changed that arm from one read to three and required all three to be
resident in system.merges at the same instant, which that budget cannot grant; every miss then spent
the whole 150-iteration wait, which is what pinned those runs past the arm's own deadline. The three
green legs were simply fast enough (43-76s per run against 117-139s) to get their slots.

So the arm is back to a single read, and its window back to the 0.5s that was green on all five legs two
heads ago. The resonance fixes from the previous round are kept, and the reference file is unchanged.

Verified against a thread-fuzzer TSAN server run with --jobs 18, which reproduces the CI failure
exactly: unfixed 0 OK / 18 FAIL with the premise as the only reddened cell, fixed 162 OK / 0 FAIL across
three batches (p50 26s, max 44s against the 180s per-test limit). With the mutate-path latch store
removed the fixed test fails 18 of 18 and toggle stop/start cancels the read is the only cell that
reddens, so the arm still detects what it is there for.

Session id: cron:clickhouse-maint-slot-12:20260923-142900

groeneai and others added 3 commits October 8, 2026 15:13
…tion-cancellation-predicate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master now installs merge and mutation cancellation predicates on the thread
group itself (`MergeTask::prepare` and the `MutateTask` constructor, for the
vector similarity index build). Reconcile this PR with that:

- Drop `ThreadGroup::setCancellationPredicates`; master's
  `setQueryCancellationPredicates` is the same setter.
- The mutation predicate installed in `mutatePartToTemporaryPart` was
  overwritten by the `MutateTask` constructor, which runs right after it,
  so it is removed and the constructor's predicate is latched instead: a
  `SYSTEM STOP MERGES` / `START MERGES` toggle between two polls must not
  resurrect a cancelled read. Measured on master: this is the only oracle of
  04826 that still fails there.
- The interactive-cancel callback persists what it observed into the entry's
  flag. It polls far more often than the S3 read, which retries every 5 s, so
  it is usually the only poller that sees a short-lived blocker; latching the
  constructor's predicate alone left the toggle arm red (0 of 3).
- The merge predicate stays where it is. `MergeTask::prepare` installs its own
  only at its end, after the reads that hang on a dead S3 endpoint: on master
  all five cancellation arms of `test_merge_cancel_s3_read` still fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pare

`MergeTask::prepare` replaces the thread group's predicates at its end with
`ctx->is_cancelled`, whose TTL term was only `need_remove_expired_values`. A
`TTLRecompress` merge leaves that false, so once `prepare` was done
`SYSTEM STOP TTL MERGES` no longer reached its reads, although the predicate
installed before `prepare` cancels it. Both now carry the same condition, so the
merge itself also stops at the next block, as `prepare` already does when it
starts.

The recompression arm of `test_merge_cancel_s3_read` stalled inside `prepare`
(loading statistics and marks), so it could not see this. Its new warm variant
pre-loads the marks and disables statistics, so the stalled request is the first
data read on a reader pool thread, after the replacement: it fails without this
change and passes with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CheSema

CheSema commented Oct 29, 2026

Copy link
Copy Markdown
Member

@groeneai Please address #128164 in a separate PR, not in this one. It builds on this PR: the predicates here read MergeListElement::is_cancelled, but nothing sets it when a merge fails, so the other in-flight S3 reads of a failed merge keep retrying.

@CheSema
CheSema added this pull request to the merge queue Oct 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 29, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged. I'm working on #128164 in a separate PR built on this one (extending test_merge_cancel_s3_read); I'll follow up here with the link (or my findings).

@groeneai

Copy link
Copy Markdown
Collaborator Author

I opened #128185 for #128164, stacked on this PR (its change is the last commit). Could you add can be tested there so CI runs?

`s3_validate_request_settings` is a query setting, and a disk definition
never reads it. Since ClickHouse#118440 the server refuses to start on an unknown
element in a disk definition (`Code: 137 ... Unknown element in the
definition of the disk broken_s3 of type s3: s3_validate_request_settings`),
so on current master every case of the module failed at setup with a
timeout waiting for the instance to start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Since #118440 (merged on 2026-10-14, after the last CI run here) the server refuses the unread s3_validate_request_settings key in the disk definition of test_merge_cancel_s3_read, so that module could not start on current master. I removed the key in 2ff5b11.

@CheSema
CheSema enabled auto-merge November 2, 2026 14:13
@CheSema
CheSema disabled auto-merge November 2, 2026 14:13
@CheSema
CheSema added this pull request to the merge queue Nov 2, 2026
Merged via the queue into ClickHouse:master with commit 356ae39 Nov 2, 2026
179 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 2, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Two Stress test hung checks on the 26.9 branch are stuck in the S3 retry loop that this PR makes cancellable for mutations. Neither 26.9 nor 26.10 contains this PR, and no backport PR exists.

In both runs the DROP DATABASE ... SYNC after 05291_system_mutations_hide_secrets waits in removeTasksCorrespondingToStorage for a running mutation (824 s in the first one). In the first run's gdb.log that mutation thread is in MutateTask::prepare -> isStorageTouchedByMutations -> the IN set build -> S3::Client::HeadObject -> AWS RetryRequestSleep, against the dead http://127.0.0.1:1 endpoint that 05291 reads (05291 reached 26.9 by backport).

A v26.9-must-backport / v26.10-must-backport label would let the robot backport it. I have not checked whether the cherry-pick applies cleanly.

@clickhouse-gh clickhouse-gh Bot added comp-background-ops Background pools/scheduling for merges, cleanup, maintenance. and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. 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-background-ops Background pools/scheduling for merges, cleanup, maintenance. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default 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.

4 participants