Repository navigation
Do not let cancellation interrupt the rollback of a merge or mutation - #127263
Conversation
When a mutation is killed while its part is being committed, the commit fails and `MergeTreeData::Transaction::rollback` runs in the thread of the mutation, under its query cancellation predicates. Reading the version metadata in `setAndStoreCreationCSN` then threw `Cancelled mutating parts` (in ClickHouse Cloud, from the distributed cache read buffer), so the rolled back part was left Outdated without `RolledBackCSN`. Such a part is not skipped by `getMaxLevelMutationInBetween`, and merges of its neighbours (including `OPTIMIZE ... FINAL`) are refused with "There is an outdated part in a gap between two active parts" until it is removed. This made `01168_mutations_isolation` flaky: `OPTIMIZE TABLE mt FINAL` in tx 7 did nothing, so the mutation of tx 10 did not get the expected serialization error, and the mutation of tx 7 failed instead. Use `ThreadStatus::QueryCancellationBlocker` during the rollback, as `MergeTreeTransaction::rollback` does. Related: ClickHouse/clickhouse-private#13092 Example failure: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=82719&sha=b87fa9bb1fa635e3ef67043098f0931d959a45ca&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20cache%2C%20meta%20in%20keeper%2C%20s3%20storage%2C%20parallel%29 PR: ClickHouse/clickhouse-private#82719 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [1e772fe] Summary: ✅
AI ReviewSummaryReviewed PR #127263 at Missing context / blind spots
Final Verdict✅ Approve. No code changes requested. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (-74.43 KiB total), 1 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units7 translation units recompiled, 45 s compile time in total, 7 of them have a recent master baseline. |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127263&sha=85c0301d2b5d76006ff1e2096b1bcfac0dce2689&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 ( The other failures ( |
|
This is the rolled-back In this run the stress phase ran v26.9.24.8. #122375 (merged 2026-10-09) is in master and in the 26.10 branch, but in no 26.9 release (checked up to v26.9.25.15). The Upgrade check installs the newest release below the PR's version ( Until then, PR CI stops blocking on it if an open issue labelled |
|
🕵 Thanks, @groeneai. So this is the rolled-back |
alexey-milovidov
left a comment
There was a problem hiding this comment.
LGTM, approved.
|
Backporting to fix CI |
Backport #127263 to 26.10: Do not let cancellation interrupt the rollback of a merge or mutation
…back of a merge or mutation
When a mutation is killed while its part is being committed, the commit fails, and
MergeTreeData::Transaction::rollbackruns in the mutation's thread, under the mutation's query cancellation predicates. Reading the version metadata insetAndStoreCreationCSNthen threwCancelled mutating parts(in ClickHouse Cloud, from the distributed cache read buffer). As a result, the rolled-back part was left Outdated withoutRolledBackCSN.getMaxLevelMutationInBetweendoes not skip such a part, so merges of its neighbours, includingOPTIMIZE ... FINAL, are refused withThere is an outdated part in a gap between two active partsuntil the part is removed.This made
01168_mutations_isolationflaky in the private repository. Sequence:kill mutationcancelledmutation_15.txtof tx 8 just as it was committingall_1_1_0_15. TheRolledBackCSNstore for that part failed.OPTIMIZE TABLE mt FINALin tx 7 then did nothing, the mutation of tx 10 succeeded instead of getting the expected serialization error, and the mutation of tx 7 failed withpart all_1_1_0_13 is locked by transaction ....The fix holds a
ThreadStatus::QueryCancellationBlockerduring the rollback, asMergeTreeTransaction::rollbackalready does. The blocker is also carried intoThreadPooljobs, so it covers the asynchronous remote reader.Example failure: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=82719&sha=b87fa9bb1fa635e3ef67043098f0931d959a45ca&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20cache%2C%20meta%20in%20keeper%2C%20s3%20storage%2C%20parallel%29
Related: https://github.com/ClickHouse/clickhouse-private/pull/82719
Related: https://github.com/ClickHouse/clickhouse-private/issues/13092
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127263]
Version info
26.11.1.694-master(included in26.11and later)26.10.3.19