Repository navigation
Set Keeper component in StorageMergeTree mutation-file methods - #109297
PedroTadim merged 2 commits into
Conversation
Pre-PR validation gate (click to expand)
Origin: handoff of a public-code fix that syncs to the private repo; the affected Session id: cron:clickhouse-worker-slot-4:20260703-131800 |
|
cc @CurtizJ @alesapin — could you review this? It adds |
|
Workflow [PR], commit [cbccea3] Summary: ❌
AI ReviewSummaryThis PR adds Final VerdictStatus: ✅ Approve |
CI finish ledger — f9233eaEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
No PR-caused failure: this PR touches only Session id: cron:our-pr-ci-monitor:20260703-173000 |
|
Ledger update for the Fixing PR: #109178 (external, open) "Preserve original key order in bucketed Map serialization". Root cause: bucketed Map serialization (#99200) reorders map keys by hash bucket, breaking positional Our own competing PR #104540 was closed 2026-07-02 in favour of #109178. |
f9233ea to
970ba2d
Compare
|
Rebased onto current master to resolve the merge conflict; force-pushed |
StorageMergeTree methods that perform MergeTreeMutationEntry disk I/O (commit / removeFile / writeCSN, and reading entries at load) can reach Keeper when the table's disk stores metadata in Keeper (metadata_type='keeper'). With enforce_keeper_component_tracking=1 the ZooKeeper request path requires a thread-local component scope set via Coordination::setCurrentComponent; without it the request throws LOGICAL_ERROR: "Current component is empty, please set it for your scope using Coordination::setCurrentComponent", which aborts the server in debug and sanitizer builds. One concrete trigger: KILL MUTATION on a MergeTree table on a keeper-metadata disk -> killMutation -> MergeTreeMutationEntry::removeFile -> disk existsFile -> Keeper multi request with no component scope. StorageSharedMergeTree already annotates its Keeper-touching call sites with setCurrentComponent guards; StorageMergeTree had none. Add a scoped guard covering every path that does MergeTreeMutationEntry disk I/O: - setMutationCSN, killMutation, loadMutations, clearOldMutations: guard at method entry. - alter and startMutation: guard at method entry rather than inside the prepareMutationEntry helper. The helper commits mutation_*.txt but leaves the entry unregistered (is_registered == false) and returns it to the caller; the caller may then remove that file LATER and OUTSIDE the helper scope -- on the pre-commit unwind (the PreparedMutationEntry destructor runs removeFile), on the explicit alter rollback (held_entry->removeFile), or when addPreparedMutationEntry throws in startMutation. Guarding the whole caller path keeps the component scope active across the commit AND the rollback removeFile. prepareMutationEntry itself no longer sets a guard because both of its callers now do. These cover all mutation-entry disk I/O sites in the file, including the destructor removeFile paths. The guards are unconditional, valid public code and a harmless no-op in builds without a keeper-metadata disk (plain disks do not route these operations through Keeper). No behavior, format, or setting change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
970ba2d to
4e962f4
Compare
|
You are right, that was a real hole.
Both run after
Pushed as 4e962f4. Verified on a plain-disk build with |
CI finish ledger — 4e962f4CI fully finished on this head (Finish Workflow completed 2026-07-04T16:44:02Z, no checks queued/in_progress). Every failure has an owner.
No test-level failures. Session id: cron:our-pr-ci-monitor:20260704-170000 |
Algunenano
left a comment
There was a problem hiding this comment.
@groeneai Please don't be so verbose with the comments. In this case they are unnecessary. Please remove them
|
@groeneai please trim the comments. I need this PR to get merged |
Requested by reviewers: the setCurrentComponent guards mirror the existing StorageSharedMergeTree pattern and are self-explanatory; the rationale lives in the PR description. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@Algunenano done, comments removed in cbccea3. The guards mirror the StorageSharedMergeTree pattern and the rationale is in the PR description. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 13/14 (92.86%) · Uncovered code |
CI finish ledger — cbccea3CI is complete. This commit only trims code comments (per @Algunenano / @PedroTadim) — the guard logic is unchanged. The only non-green check is a pre-existing perf-comparison instability, not caused by this PR.
Session id: cron:our-pr-ci-monitor:20260707-220000 |
8a863a7
…ee-keeper-component-tracking Set Keeper component in StorageMergeTree mutation-file methods
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
LOGICAL_ERROR(Current component is empty) that could be raised by mutation operations such asKILL MUTATIONon aMergeTreetable that stores its metadata in Keeper, when theenforce_keeper_component_trackingserver setting is enabled.Description
StorageMergeTreemethods that performMergeTreeMutationEntrydisk I/O (commit/removeFile/writeCSN, and reading entries at load) can reach Keeper when the table's disk stores its metadata in Keeper (metadata_type='keeper'). Withenforce_keeper_component_tracking=1, the ZooKeeper request path requires a thread-local component scope set viaCoordination::setCurrentComponent. Without it the request raisesLOGICAL_ERROR: Current component is empty, please set it for your scope using Coordination::setCurrentComponent, which is caught and handled in release builds but aborts the server in debug and sanitizer builds.One concrete trigger:
KILL MUTATIONon such a table ->StorageMergeTree::killMutation->MergeTreeMutationEntry::removeFile-> diskexistsFile-> Keeper multi request with no component scope up the stack.StorageSharedMergeTreealready annotates its Keeper-touching call sites withsetCurrentComponentguards;StorageMergeTreehad none. This adds a scoped guard at the entry of everyStorageMergeTreemethod that doesMergeTreeMutationEntrydisk I/O:startMutation,setMutationCSN,killMutation,loadMutations,clearOldMutations. Together these cover all nine mutation-entry I/O sites in the file.The guards are unconditional, valid public code and a harmless no-op in builds without a keeper-metadata disk (plain disks do not route these operations through Keeper), matching the accepted
StorageSharedMergeTreeguard pattern. No behavior, on-disk format, or setting change.No related open issue found (checked open/closed issues and open PRs). A targeted regression test would need a keeper-based metadata disk (
metadata_type='keeper'), whose registration is gated behind a build flag not available in a community build, so this is a source-only fix; the affected path is not reachable on a plain community checkout.Version info
26.7.1.704(included in26.7and later)