Repository navigation
Check a local part with no node in ZooKeeper instead of fetching it - #119189
Conversation
A part that is in the working set while its node under `replicas/<r>/parts/` is gone - a state crash recovery can leave behind - wedged the replication queue: the already-have-it guard skips an entry only when the node exists, so the `GET_PART` entry fetched the whole part from a peer and then threw `DUPLICATE_DATA_PART` for the copy that was already there, forever, re-downloading the part every round. The merge selection has always enqueued such a part for check instead of using it. The fetch path now does the same and stops: the part check thread adds the node back when the local part is intact and detaches the part when it is not, and the entry is then either skipped or unobstructed. Closes: #118002
|
Workflow [PR], commit [e7dedb2] Summary: ❌
AI ReviewSummaryThis PR correctly stops the immediate Findings❌ Blockers
Tests
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit e7dedb2.
Changed lines: Changed C/C++ lines covered: 35/35 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
The test removes the part's node under `replicas/<r>/parts/` by hand and then watches the `ReplicatedMergeTree` queue entry written for it. Neither structure exists when the engine is substituted for one that keeps its metadata elsewhere, so the test asserted nothing there and failed. Tag it `no-shared-merge-tree`.
…ssing-in-zk-118002
`MERGE_PARTS` and `MUTATE_PART` entries never reach `executeLogEntry`: `scheduleDataProcessingJob` sends them to `MergeFromLogEntryTask` and `MutateFromLogEntryTask`, whose shared `ReplicatedMergeMutateTaskBase::checkExistingPart` only skipped the entry when the local part's node under `replicas/<r>/parts/` exists. So the same state - the part is `Active` locally while its node in ZooKeeper is gone - still fell through to the merge, the mutation, or, when `prepare` declines the local execution (`always_fetch_merged_part`, `always_fetch_mutated_part`, single-replica merge selection, missing source parts, zero-copy handoff), to `executeFetch`. Each of those produces the part that is already there and throws `DUPLICATE_DATA_PART`, which is the loop this pull request is about. `checkExistingPart` now enqueues such a part for check and reports `PART_MISSING_IN_ZOOKEEPER`, the same reconciliation the `GET_PART` and `ATTACH_PART` path does. No exception is thrown there, because `ReplicatedMergeMutateTaskBase::executeStep` does not save a `PART_IS_TEMPORARILY_LOCKED` exception and the queue's exponential backoff is armed by `updateLastExeption`; the task asks the background assignee to postpone the next attempt instead, through the existing `postpone_next_attempt`. Also renumber the test to `05229` - `05188` was taken on master meanwhile - and add `05230_merge_entry_for_local_part_missing_in_zookeeper` for the merge entry. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| * or a mutation of the local source parts, or a fetch from a peer when `prepare` declines the | ||
| * local execution - `renameTempPartAndReplaceImpl` throws `DUPLICATE_DATA_PART` for the part | ||
| * that is already there, and nothing in the retry path reconciles the two, so the entry is | ||
| * retried forever. The part check thread is what reconciles it: it adds the missing node when |
There was a problem hiding this comment.
The new guard assumes that enqueuePartForCheck will preserve an intact local part by re-adding its missing Keeper node, but that is not what the reconciler does today. In ReplicatedMergeTreePartCheckThread::checkPartImpl, the "part exists locally, but /replicas/<r>/parts/<name> does not" branch just waits until the part is older than MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER, then returns DetachUnexpected (ReplicatedMergeTreePartCheckThread.cpp:450); outdateUnexpectedPartAndCloneToDetached then removes the active part from the working set instead of recreating the znode (MergeTreeData.cpp:7466).
So this PR no longer wedges on DUPLICATE_DATA_PART, but it fixes the queue by eventually dropping a still-readable part and relying on a later fetch/re-merge. If this replica is the only place that still has valid data for the result part, that follow-up path can even fall through to the existing "lost forever" handling. I think the fix needs a real "repair Keeper metadata for an intact local part" step here, or a different reconciliation path that keeps the part active while restoring its node.
A part that is
Activelocally while its node underreplicas/<r>/parts/is gone - a self-inconsistent state crash recovery can leave behind - wedged the replication queue for good. TheGET_PARTentry for that part was executed, because the already-have-it guard inexecuteLogEntryskips an entry only when the local part's node exists; the fetch then downloaded the whole part from a peer andrenameTempPartAndReplaceImplthrewDUPLICATE_DATA_PARTfor the copy that was already there. Nothing in the retry path reconciles the two, so the entry was retried forever:SYSTEM SYNC REPLICAnever returned, the queue stayed non-empty for monitoring, and every round re-downloaded the part just to throw it away.The merge selection has handled this state for a long time - a part that "exists locally but not in ZooKeeper" is not used for a merge and is enqueued for a check. The fetch path now does the same: it enqueues the part for check and stops instead of fetching. The part check thread is the designed reconciler - it adds the missing node when the local part is intact and detaches the part when it is not - and after it runs, the entry is either skipped by the guard above or has nothing in its way. The entry stays in the queue meanwhile, where the exponential backoff of a failed entry keeps the retries apart, and a retry now costs nothing.
Closes: #118002
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed the replication queue never draining when a part is present locally but its node in ZooKeeper is missing: the
GET_PARTentry for such a part re-downloaded it and failed withDUPLICATE_DATA_PARTon every retry. The part is now enqueued for a check, which reconciles the state.Workflow [PR]
Sync PR [sync-upstream/pr/119189]
Version info
26.10.1.323-master(included in26.10and later)