Skip to content

Do not merge patch parts across a pending mutation version - #113998

Closed
groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:fix-98898-patch-merge-crossing-mutation
Closed

groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:fix-98898-patch-merge-crossing-mutation

Conversation

@groeneai

@groeneai groeneai commented Aug 9, 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 a permanently stalled mutation on ReplicatedMergeTree tables with lightweight updates enabled. A merge of patch parts could produce a patch whose source data versions span the version of a mutation that is still queued, which no mutation can then apply, so the MUTATE_PART entry failed and retried forever (Found patch part ... that intersects mutation with version ...). Such merges are now postponed until the mutation completes.

Description

Related: #98898

A patch part records the data-version range of what it patches, and applies whole or not at all. Merging patch parts unions those ranges, so merging patches for versions 1 and 6 yields one spanning 1..6. A mutation cutting at version 2 cannot apply it, patchHasHigherDataVersion throws, and the MUTATE_PART entry retries forever. Debug and sanitizer builds abort, hence the stress failures.

Root cause: the merge predicate already refuses parts whose current mutation versions differ, but derives them from mutations_by_partition, where getCurrentMutationVersion returns 0 for an absent partition. The finished-mutation cleaner removes the /mutations znodes once every replica's mutation_pointer passed them, while the MUTATE_PART entries survive. Every patch then maps to 0 and every pair looks mergeable. The logs show There are no mutations for partition ID all just before the abort.

The fix takes the pending versions from the replication queue instead, which is durable: a queued MUTATE_PART entry's new_part_name encodes its target version. A patch MERGE_PARTS whose sources would span one is postponed, so it proceeds once the mutation completes. No assertion is relaxed, and the cost is one walk of a queue the neighbouring guards already walk.

The repro is deterministic: pristine master aborts with the exact message, the fix passes, and deleting only the new guard call brings the abort back. The test asserts the mutation completes, the queue drains and the data is fully patched, so no deadlock or dropped patch passes.

Two limits. Like the guards beside it, this is an execution-side per-replica check: it stops a replica merging across a mutation queued there, not every route by which a spanning patch could reach one. And it does not repair a patch already spanning a version on disk, so such a table stays stuck; that needs per-row _data_version filtering when applying patches.

A patch part records the data-version range of the rows it patches, and a patch
applies whole or not at all. SourcePartsSetForPatch::merge unions those ranges,
so merging patches for data versions 1 and 6 produces one patch spanning 1..6.
A mutation cutting at version 2 has no valid way to apply that patch, so
patchHasHigherDataVersion throws LOGICAL_ERROR from MutateTask::prepare, the
MUTATE_PART entry fails and retries forever, and the mutation never completes.
Debug and sanitizer builds abort instead, which is how this surfaces in the
stress tests. Reported as ClickHouse#98898.

DistributedMergePredicate::canMergeParts already refuses to merge two parts
whose current mutation versions differ, and it is applied to every adjacent
pair, so with durable metadata it does refuse this pair. It fails because
ReplicatedMergeTreeQueue::getCurrentMutationVersion returns 0 for a partition
that is absent from mutations_by_partition, which is indistinguishable from a
partition that has no mutations at all. The finished-mutation cleanup thread
deletes the /mutations znodes once every replica's mutation_pointer has passed
them and updateMutations erases the in-memory entries, while the MUTATE_PART
queue entries survive. Every patch then maps to version 0, both endpoints
compare equal, and every pair looks mergeable.

Take the pending mutation versions from the replication queue instead, which is
the durable record: a queued MUTATE_PART entry's new_part_name encodes its
target version. isMergeOfPatchPartsCrossingMutation postpones a patch
MERGE_PARTS entry whose source data versions would span such a version, modelled
on the existing isDropOfPatchPartBlocked. Postponing is self-healing: the
patches stay unmerged with singleton spans, the mutation proceeds, and the merge
runs afterwards. The assertion in patchHasHigherDataVersion is left untouched,
since after this change a straddling patch is never constructed.

This prevents the bad state from being created. It does not repair a patch that
already spans a mutation version on disk, so a table already in that state stays
stuck; recovering those requires filtering patch rows by their per-row
_data_version in the patch apply path.

The plain MergeTree predicate has no equivalent hole: StorageMergeTree::
clearOldMutations bounds deletion by getMinPartDataVersion(), so a mutation with
pending work is never pruned from current_mutations_by_version.

The new test reproduces the failure deterministically by holding the MUTATE_PART
in prepare() with the rmt_mutate_task_pause_in_prepare fail point while the
patch merge is decided. It asserts that the mutation completes, that the
replication queue drains, and that the values are fully patched, so neither a
postponed-forever merge nor a silently dropped patch can pass it.
…ation

The wait loop broke out as soon as a patch MERGE_PARTS entry was present in
system.replication_queue. Presence is established by pullLogsToQueue, which
strictly precedes selectEntryToProcess evaluating the entry, so the test could
disable the fail point while the patches were still unmerged singletons. Without
the guard the released mutation then snapshots singleton spans, finds no
straddle and completes, the MUTATE_PART entry is gone, and the later patch merge
produces the straddling patch with nothing left to trip on it. The queue drains,
the values are fully patched, and the test passes on a binary that still has the
bug. The loop also had no failure branch, so a timeout was indistinguishable
from success.

Wait for a positive, guard-specific observation instead: a patch MERGE_PARTS
entry with num_postponed > 0 whose postpone_reason names the version span, or an
already merged level > 0 patch part. The reason substring occurs once in the
whole source tree, and postpone_reason is filled regardless of log level because
LogToStrImpl::log assigns the string before the propagation check. Post-fix only
the postponed branch can fire while the MUTATE_PART is queued, and pre-fix only
the merged branch exists, so the loop is satisfiable in both directions while
the branch taken is what discriminates. Neither arm can reach the other's
branch. A timeout is now a hard failure that dumps the queue and the active
parts, following 03716_mutations_parts_postpone_reasons_mt.

Verified against four binaries: the fix passes and takes the postponed branch,
pristine master and a variant with the guard call deleted both fail with the
original abort, and the fix with the postpone_reason pattern corrupted fails on
the timeout branch, which proves the new condition is load-bearing.
…ide effect

The wait loop accepted either the guard's refusal or the mere existence of a
merged patch part. The second alternative is satisfiable by a merge of patches
that all sit above the mutation version, which the guard correctly permits, so
the crossing merge was never necessarily evaluated against the queued mutation
and the test could pass on a binary without the guard. Only the guard-specific
postpone reason is accepted now, and failing to observe it is a hard failure
rather than a fall-through.

Stopped merges block execution of MERGE_PARTS and MUTATE_PART alike while
assignment of both keeps running, so the scenario is now built up entirely
inside the stopped window and released afterwards. The mutation entry is waited
for before its metadata is killed, because ALTER returns before the entry is
assigned when mutations_sync is 0, and its survival past the kill is asserted:
that state is the subject of the test.

The failpoint is PAUSEABLE and pauses every MUTATE_PART on the server with no
timeout, so an early exit under set -e would hang later unrelated tests to
their timeout. Release it from an EXIT trap as well.
@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (3 rounds, 4 gate runs) - 1 accepted, 4 noted, all resolved before publishing

I put this through three independent cold-review rounds plus four adversarial gate runs before opening it. Recording what was raised and how I resolved it, so nobody re-derives it.

Rounds 1-2 (test oracle, both accepted and fixed). The first version of the regression test could pass GREEN on a binary without the fix. It waited for a patch MERGE_PARTS entry merely to be PRESENT in system.replication_queue, but presence is established by pullLogsToQueue, which strictly precedes the entry being evaluated. In that window an unfixed binary resumes the mutation, snapshots singleton-span patches, finds no straddle and completes, after which the merge produces the spanning patch with nothing left to trip on it. Round 2 then found a second escape hatch: the loop also accepted any active level > 0 patch part, which is satisfiable by a merge of patches that all sit ABOVE the mutation version and that the guard correctly permits, so the crossing merge was never necessarily evaluated. The loop now accepts exactly one thing, the guard's own refusal (num_postponed > 0 and a postpone_reason naming the version span), and failing to observe it is a hard failure with a queue dump rather than a silent fall-through. Verified load-bearing by corrupting only the postpone_reason pattern: the fixed binary then fails on timeout while its dump shows the real reason and num_postponed: 39. Also fixed in round 2: the test enables a PAUSEABLE server-global fail point that blocks every later MUTATE_PART with no timeout, and under set -e an early exit would leak it and hang unrelated tests. It is now released from an EXIT trap, following 03716_mutations_parts_postpone_reasons_rmt.sh. Measured, not argued: with the trap removed one leaked fail point left a later unrelated ALTER ... UPDATE at is_done = 0 for 20 s.

❌ Round 3, accepted: the description over-claimed its own scope. A reviewer pass argued a replica can still end up with a spanning patch without ever merging one, by fetching it as a covering part. I could not refute any step of that: the MERGE_PARTS entry is a cluster-wide log entry, this check is execution-side and reads only the local queue, a replica that already finished the mutation no longer holds the entry and so permits the merge, and the covering-part substitution in findReplicaHavingCoveringPart picks the largest containing remote part while addFuturePartIfNotCoveredByThem validates only containment, drop-part intersection and future-part overlap, never a mutation boundary. So the mechanism is real. It is not introduced here (this diff touches no fetch path; it is two functions in ReplicatedMergeTreeQueue plus a test) and it is shared by every guard in this family, all of which are per-replica execution-side checks. But the sentence "this prevents the bad state from being created" was mine and was wrong, so I rewrote the description to state the scope precisely instead of leaving a claim I cannot support. Closing the remaining route means validating a fetched substitute against queued mutations, which is a separate design: refusing a fetch has none of the self-healing postpone semantics that make refusing a merge safe, and getting that wrong trades an exception for a stall. I am not promising a follow-up I have not measured.

⚠️ Noted, not changed. The guard reads its span from part names, and getDataVersion() returns a patch's source-set maximum, so it under-detects when a source patch ALREADY spans. That region is empty for a healthy table: such a source trips the assertion on its own, and no new MUTATE_PART can be assigned inside its span because getExpectedMutationVersion returns nothing for a partition with no mutation metadata. It cannot take a healthy table to broken.

⚠️ The test's MUTATE_PART wait loop has no failure branch of its own, so an assignment timeout would be reported as "No MUTATE_PART entry survived the kill". The condition is still caught and still fails; only the message misattributes it.

💡 The test carries no no-async-insert tag, unlike two of the four in-tree users of this fail point. The lightweight updates here do not go through the async-insert queue and the test asserts no part names or versions, so the worst case is a loud timeout rather than a false pass. I would rather leave the tag off than add a skip on speculation.

For calibration: after the description was corrected, the final gate run over the byte-identical tree returned zero findings.

Session id: cron:clickhouse-review-slot-49:20260808-231800

@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. ReplicatedMergeTree with enable_lightweight_update, one lightweight UPDATE (patch at data version 1), an ALTER TABLE ... UPDATE held in prepare() via the rmt_mutate_task_pause_in_prepare fail point (mutation version 2), four more lightweight updates (patches at 3..6), then the mutation metadata removed while its MUTATE_PART entry stays queued, then merges started. Fires on every attempt, not intermittently. Shipped as the regression test.
b Root cause explained? Yes. Merging patch parts unions their source data-version ranges, so a merge of patches at 1 and 6 yields a patch spanning 1..6, which no mutation cutting at version 2 can apply. The pair check in DistributedMergePredicate::canMergeParts should have refused that pair, but it reads mutations_by_partition, and getCurrentMutationVersion returns 0 for a partition absent from it. The finished-mutation cleaner removes the /mutations znodes while the MUTATE_PART queue entries survive, so every patch maps to 0 and every pair looks mergeable.
c Fix matches root cause? Yes. It refuses the merge that creates the unusable patch, at the merge decision, taking pending mutation versions from the durable replication queue rather than from the prunable metadata. Not a guard at the throw site, no relaxed assertion, no widened bound, no no-random-* tag, no reduced data.
d Test intent preserved / new tests added? New stateless test 03100_lwu_56_patch_merge_crossing_mutation. No existing test weakened or removed. It accepts only the guard's own refusal of the crossing merge, and then asserts the mutation completes, the replication queue drains, and the values are fully patched, so a postpone-forever regression, a dropped patch, or a scenario that never reached the state under test all fail it.
e Both directions demonstrated? Yes, with the serving binary's build id verified at the listening process on every run. Pristine master aborts with the exact upstream message and an identical stack; deleting only the new guard call brings the abort back, repeated six times, including runs where the merge that does not cross the mutation version is allowed to complete first; with the fix the test passes. A further arm corrupts only the test's guard-specific wait condition on the fixed binary, and the test then fails on its timeout branch, so that condition is load-bearing rather than incidental. Three vacuous forms of the test were caught this way across review rounds and fixed before being relied on. The fail point release is likewise proved load-bearing by a paired control that differs only by the EXIT trap: without it the fail point stays enabled after an early exit and a later unrelated mutation then hangs; with it the fail point is released. 50/50 randomized runs green.
f Fix is general across code paths? The invariant has exactly one creator: a patch-part MERGE_PARTS reaching shouldExecuteLogEntry, which has a single call site and no engine-specific override. Fixed there. Every sibling guard and both detector call sites re-read and confirmed correct as-is. The plain MergeTree predicate has no equivalent hole: clearOldMutations bounds deletion by getMinPartDataVersion(), so a mutation with pending work is never pruned.
g Fix generalizes across inputs (params/datatypes/wrappers)? The guard reads only part names, so it is independent of column types and wrappers. Boundary behaviour matches the assertion exactly: it fires iff min <= V < max, so a patch whose span ends at V stays legal, a single-source or equal-version entry short-circuits, and patches for other partitions are skipped by original partition id.
h Backward compatible? Yes. No setting, no default change, no format or serialization version change, so no SettingsChangesHistory.cpp entry. The only behaviour change is postponing a merge that would otherwise produce an unusable patch.
i Invariants and contracts preserved? Yes. The function is const, takes the same state_mutex lock its three siblings take and callers already hold, allocates nothing beyond two integers per queue entry, and can only throw via fromPartName on a malformed name, which the surrounding code already parses from the same strings. Postponing rather than failing is the established mechanism at this call site and is self-healing; liveness is asserted by the test rather than assumed.

Session id: cron:clickhouse-review-slot-49:20260808-231800

@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ @tavplubix, could you review this? Merging patch parts unions their source data-version ranges, so a merge can produce a patch spanning a queued mutation's version, which no mutation can apply; the pair check that should refuse it reads mutation versions from mutations_by_partition, which the finished-mutation cleaner prunes while the MUTATE_PART queue entries survive, so this takes the pending versions from the replication queue instead.

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

clickhouse-gh Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2c3cf9c]

Summary: ✅


AI Review

Summary

This PR moves the "do not merge patch parts across a queued mutation version" check from mutations_by_partition to the replication queue and adds a deterministic regression test for the local postpone path. The local MERGE_PARTS executor is better protected, but a lagging replica can still fetch the already-merged covering patch from another replica and hit the same permanent stall, so the bug from #98898 remains reachable in replicated setups.

Findings

❌ Blockers

  • [src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp:333-379] The new guard only blocks local MERGE_PARTS execution. A replica can still have a queued MUTATE_PART and missing lower-version patch GET_PARTs (ReplicatedMergeTreeQueue::havePendingPatchPartsForMutation), fetch the already-merged covering patch via StorageReplicatedMergeTree::findReplicaHavingCoveringPartImplLowLevel / ReplicatedMergeTreeQueue::addFuturePartIfNotCoveredByThem, and then hit the same patchHasHigherDataVersion exception when ReplicatedMergeTreeQueue::getMutationsSnapshot reloads active patch parts. Suggested fix: enforce the same "no spanning patch across a queued mutation version" invariant in covering-part fetch/substitution, not only in local merge execution.
Tests
  • ⚠️ The new regression test is single-replica and only proves the local postpone path. Add a focused two-replica case where one replica still has the queued mutation while another has already produced the merged patch, then verify the lagging replica does not fetch that covering patch and stall.
Final Verdict

Request changes: the queue-side guard is only a partial mitigation, and the original permanently stuck replication state is still reachable through covering-part fetch.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.60% 86.60% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.80% 78.80% +0.00%

Changed lines: Changed C/C++ lines covered: 34/35 (97.14%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 9, 2026

auto original_partition_id = new_part_info.getOriginalPartitionId();

for (const auto & mutate_entry : queue)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

queue is only one carrier of the "pending mutation version" invariant here, so blocking local MERGE_PARTS execution is not sufficient to eliminate the stuck state.

A replica can still have a queued MUTATE_PART plus missing lower-version patch GET_PARTs (ReplicatedMergeTreeQueue::havePendingPatchPartsForMutation, lines 446-456). If another replica has already produced the merged patch, StorageReplicatedMergeTree::findReplicaHavingCoveringPartImplLowLevel will substitute the missing patch with the largest covering remote part, and ReplicatedMergeTreeQueue::addFuturePartIfNotCoveredByThem only checks queue/drop/future-part ordering, not whether that covering patch spans a queued mutation version. After that fetch, ReplicatedMergeTreeQueue::getMutationsSnapshot still reloads the active spanning patch and patchHasHigherDataVersion throws the same LOGICAL_ERROR.

So this closes the local merge path, but a lagging replica can still import the bad patch via covering-part fetch. I think the same boundary check needs to be enforced in the covering-fetch/substitution path as well, or the permanently stuck replicated state remains reachable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The mechanism is real, and it is already stated in the PR. I reached the same conclusion in review before publishing and could not refute any step of it: the MERGE_PARTS entry is a cluster-wide log entry, this check is execution-side and reads only the local queue, a replica that already finished the mutation no longer holds the MUTATE_PART entry and so permits the merge, and findReplicaHavingCoveringPartImplLowLevel picks the largest containing remote part while addFuturePartIfNotCoveredByThem validates only virtual-parts containment, drop-part intersection and future-part overlap, never a mutation boundary.

That is why the description states the scope rather than claiming the state cannot be created: "this is an execution-side per-replica check: it stops a replica merging across a mutation queued there, not every route by which a spanning patch could reach one". The same limit is recorded in full in the adjudication comment, round 3: #113998 (comment)

Two reasons the boundary check is not added to the fetch path here:

  • This diff touches no fetch path. It is two functions in ReplicatedMergeTreeQueue plus one test, so validating a fetched substitute is a separate change in StorageReplicatedMergeTree.
  • Refusing a fetch has none of the self-healing postpone semantics that make refusing a merge safe. An earlier design that refused the operation outright was rejected on exactly that liveness dimension, and getting it wrong trades an exception for a stall.

On the suggested two-replica test: it would assert that the lagging replica does not fetch the covering patch, which is the behaviour this PR does not claim, so it would fail. I am not promising a follow-up I have not measured.

@clickhouse-gh

clickhouse-gh Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

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

⚠️ Significant changes: compile time of recompiled translation units.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 690.64 MiB 687.63 MiB -3.02 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units ⚠️

7060 translation units recompiled, 7217 s compile time in total, 43 of them have a recent master baseline.

Translation units without a recent master baseline:

  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Passes/PassBuilder.cpp: 25.6 s
  • contrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-s3/source/S3Client.cpp: 15.7 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp: 14.9 s
  • contrib/wasmedge-cmake/__/wasmedge/lib/vm/plugin_modules.cpp: 13.1 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp: 12.0 s
  • contrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-glue/source/GlueClient.cpp: 11.9 s
  • contrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-glue/source/GlueClient1.cpp: 11.9 s
  • contrib/rocksdb-cmake/__/rocksdb/db/db_impl/db_impl.cc: 10.5 s
  • contrib/wasmedge-cmake/__/wasmedge/lib/api/wasmedge.cpp: 9.7 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Passes/PassBuilderPipelines.cpp: 9.7 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp: 9.6 s
  • contrib/wasmedge-cmake/__/wasmedge/lib/vm/vm.cpp: 9.4 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp: 9.3 s
  • contrib/wasmedge-cmake/__/wasmedge/lib/host/wasi/wasimodule.cpp: 9.2 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp: 9.1 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp: 8.8 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp: 8.7 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp: 8.4 s
  • contrib/wasmedge-cmake/__/wasmedge/lib/host/wasi/wasifunc.cpp: 8.4 s
  • contrib/rocksdb-cmake/__/rocksdb/db/internal_stats.cc: 8.3 s
  • ... and 113 more

Job report

@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2c3cf9c

CI is fully finished on this commit: 161 checks pass, 17 skipped, 0 failed, 0 queued or running, and both Config Workflow and Finish Workflow completed successfully. Mergeable Check is green.

No failed check to own. CIDB reports zero FAIL or ERROR test rows for this pull request at this commit, and none at any earlier commit of it either.

Session id: cron:our-pr-ci-monitor:20260809-123000

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

The merge-queue run at d7d4258 failed on my own test 03100_lwu_56_patch_merge_crossing_mutation (Fast test 1 failure, Stateless tests (amd_binary, flaky check) 4 failures), and the PR was dropped from the queue at 01:16Z. The cause is #115064, which merged 35 minutes before that run.

Measured locally on this branch merged with current master, three arms, binary identity asserted per arm with SELECT lower(buildId()):

this PR's queue-side check #115064 patch merge assigned logical error 03100_lwu_56
present present no none fail
present source reverted yes, refused by this check none pass
absent present no none fail

The third arm is the point: with this PR's check removed and #115064 in place, no patch merge is assigned at all and the logical error does not occur. ReplicatedMergeTreeMergePredicate.cpp:68-71 takes the data versions from virtual_parts_ptr->getPartInfos(), and virtual parts already contain the results of entries still in the queue, so a version assigned by a not yet executed mutation is visible to the assignment-side check. That is the exact state this PR's queue-side check was written for, so the check is now unreachable and its test can no longer observe a refusal. The second arm confirms the test and the check both still work when #115064 is absent, so this is supersession and not a broken test.

For the record the CI signature is the arming path failing, not the property: the surviving MUTATE_PART carries the stale merges and mutations are cancelled now reason from before SYSTEM START MERGES, while num_tries: 1 and SYSTEM WAIT FAILPOINT ... PAUSE returning show the mutation did reach prepare().

I have pushed nothing. I would rather not make the test pass, since that means asserting something that can no longer happen. The one case I did not measure is a mixed-version cluster, where an older replica could still assign such a merge and this check would refuse the entry on an upgraded one. Should this be closed as covered by #115064, or kept for that case?

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=gh-readonly-queue/master/pr-113998-3c3a54e67faf096f9b51f3ef49a622406f79588b&sha=d7d42580a3528db40f22ea875e5ba3ba93e303f6&name_0=MergeQueueCI&name_1=Fast%20test

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, a redundant test should be removed. If the code changes are no longer relevant, you can close this.
If there is a relevant part, keep it.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Closing: the code change is no longer relevant.

Arm 3 of the matrix above is the answer. With this check removed and #115064 in place, no patch merge is assigned at all, so there is nothing left for an execution-side check to refuse on any path I could reach. #115064 takes the data versions from virtual_parts, which already contain the results of entries still in the queue, so a version assigned by a not yet executed mutation is visible at assignment time. The state this check was written for is refused one layer earlier, which also makes the new test unable to observe a refusal.

The one part not covered is the cross-replica route this PR already scoped itself out of: a MERGE_PARTS entry created on a replica that has finished the mutation and executed on one that has not. I could not construct that state, so I am not keeping an unreproducible check for it.

I am still tracking the Found patch part ... intersects mutation with version family in CI, with #115064 as the fix of record.

@groeneai groeneai closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants