Repository navigation
Refuse a fetch of a partition whose patches the source has not applied - #119181
Conversation
A fetch copies base parts only, and a patch part - which holds the acknowledged lightweight updates its base parts do not have yet - lives in a partition of its own, so it was never fetched: the copy silently served pre-update values. Every other part-relocation command refuses that through `assertNoPatchesForParts` and asks for `APPLY PATCHES`. Only the source's part names are known here, so the patches are compared by the data version a patch part's name carries: one the base parts have already been mutated past is no reason to refuse anything, so the fetch works as soon as the patches are applied. Closes: #118599
|
Workflow [PR], commit [c83113d] Summary: ✅
AI ReviewSummaryThe PR makes Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes3 object files changed (+106.23 KiB total), 0 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, 35 s compile time in total, 7 of them have a recent master baseline. |
|
Both CI failures are unrelated to this change. The stress test hit Related: #114254 The |
…uses-patches-118599
…n on `FETCH PARTITION` The partition-level guard took the highest data version among the partition's base parts as its bound. A part inserted after an `UPDATE` carries a higher version than the update's patch, so with such a part in the partition the patch that is still pending for the older parts passed unnoticed and the fetch again produced a copy without the acknowledged update. Use the lowest data version instead, exactly as `assertNoPatchesForParts` does for the other part-relocation commands. The test now pins a two-part layout with merges stopped: the update touches the older part only and a later insert sits above the patch. It also checks that the fetch of the unpatched later part alone stays allowed. Renumbered from `05187`, which is taken on master. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uses-patches-118599
…d `FETCH PART` A lightweight update commits its patch part on one replica, and the others learn about it through a `GET_PART` log entry. A replica that has not executed that entry yet lists the patched base part but not the patch, and neither the random replica `FETCH PART` picks nor the `log_pointer` heuristic of `FETCH PARTITION` proves that the chosen source has executed it. So the guard now takes the union of patch parts over all replicas of the source table, and still compares them against the chosen replica's base parts. The new test detaches the replica that committed the update, leaving a replica with stopped fetches as the only active source; without this change both fetches copy the pre-update rows from it. Addresses review threads on #119181 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119181&sha=e2d04af768d2ea88f0cff4c51723db642aa5d6fa&name_0=PR&name_1=Upgrade%20check%20(amd_release) and provide a fix in a separate PR. If the fix is already in progress, link it here. The The |
|
This is the same failure as on #120910 (STID 3562-39cd), not caused by this PR. The table is The fix is in progress, in two open PRs for this exact producer:
#120980 is a different producer (leftovers of Because the leftover is written by the previous release binary, merging master does not stop this red: in 30 days it hit 29 unrelated PRs (25 of them in |
…uses-patches-118599
…llReplicas` explicit `tryGetChildren` already throws on every error except `ZNONODE`, so a replica whose `parts` cannot be read is never silently skipped. Compare against `ZNONODE` explicitly and say so in a comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…with a materialized update `clearUnusedPatchParts` drops a patch part as soon as the base parts of its own replica have been mutated past it, without waiting for the other replicas. After `UPDATE` + `APPLY PATCHES`, a lagging replica can still hold the old base part while no replica holds the patch anymore, so the patch lookup over all replicas saw nothing and `FETCH PART`/`FETCH PARTITION` from that replica silently copied pre-update rows. The fetch now also refuses when any replica of the source has a part that intersects a part to be fetched with a data version above both the fetched part's data version and the lowest block they share - i.e. a newer version of the same rows. Parts that merely cover a different block range (inserted later or merged differently) never satisfy this. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The private CI replaces `ReplicatedMergeTree` with `SharedMergeTree`, which does not support `FETCH PARTITION`/`FETCH PART`, so the tests failed there with `NOT_IMPLEMENTED` or produced different results (`CH Inc sync`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t on Keeper in 05321 The tests create replicas with explicit Keeper paths and replica names, which does not work with `DatabaseReplicated` (05227 and 05255 failed in the `DBReplicated` job), so tag them `no-replicated-database`, as `03350_alter_table_fetch_partition_thread_pool` does. Address review: 05321 now waits until the patch part is gone from Keeper's `/replicas/r1/parts` as well, not only from `system.parts`, so the test exercises the stale-replica check rather than the check for remaining patches. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119181&sha=84c20efafd4ac729f9892350652853632782db0a&name_0=PR Related: #119181 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failures: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119181&sha=84c20efafd4ac729f9892350652853632782db0a&name_0=PR and provide a fix in a separate PR. If the fix is already in progress, link it here. They are unrelated to this PR and also fail on other PRs during the last 5 days:
The PR's own tests |
|
The rows were not lost. In that job the |
…for_async_insert=0 poll Case 4 inserts with `async_insert=1&wait_for_async_insert=0` and then polled `count()` 20 times (about 19 s on the arm_asan_ubsan azure lane) before printing the rows. `wait_for_async_insert=0` gives no visibility deadline, and on ClickHouse#119181 the background flush took 27.4 s, 27.1 s of it waiting for the filesystem cache priority lock while writing a 2-row part to the write-through `cached_azure` disk (Azure writes took 5 ms). The rows landed 8 s after the final SELECT, so the reference diff was caused only by the 20-iteration cap. Loop until the rows land instead. The runner's per-test timeout stays the bound, so a lost insert still fails. Same remedy as ClickHouse#123897. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
Is the check heavy?
Read the `parts` of all source replicas with one batched Keeper request instead of a round trip per replica, and find the chosen parts that intersect a part of another replica with a binary search instead of a scan, so the check is linear in the number of parts instead of quadratic in the number of parts of the partition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 > Is the check heavy? No. It only runs on
The parts are not downloaded and there are no extra Keeper reads per part. The only thing that grows with the table is the size of the |
…t in `FETCH PARTITION` checks The `parts` node of a replica in Keeper still lists parts the replica has merged or otherwise replaced until their cleanup removes them, so the stale-version and patch checks could refuse a correct fetch because of a part that is no longer live. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119181&sha=e49e58e183c0c712d8e2a10760be9e444b85ddb6&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 ( |
|
Not caused by this PR. The fix is #123121 (mine, open). This run fails query 26 of the test with |
…d Keeper request `FETCH PARTITION` read the `parts` of the chosen replica with a separate `getChildren` and then again inside the batched read of the `parts` of all replicas. Take them from the batched read instead, so the new checks add exactly one extra Keeper request per attempt (besides the `replicas` listing), regardless of the number of replicas, and the chosen parts and the patch parts come from the same read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ALTER TABLE ... FETCH PARTITION(andFETCH PART) copies base parts only and silently left the source's patch parts behind - the parts that hold the acknowledged lightweightUPDATEs the base parts do not carry yet. AfterATTACH PARTITIONthe copy served the pre-update values, with no error and no warning, while the sameSELECTon the source returned the updated ones.A patch part lives in a partition of its own (
patch-<hash>-<partition_id>), so the filter by the requested partition can never match it. Every sibling part-relocation command -MOVE PARTITION TO TABLE,REPLACE PARTITION FROM,ATTACH PARTITION FROM,DETACH PARTITION,DETACH PART- refuses this situation throughassertNoPatchesForPartsand tells the user to runAPPLY PATCHESfirst; the fetch was the one boundary with no such guard.The fetch now refuses it the same way. Only the source's part names are known here, so the patches are compared by the data version their names carry (the mutation component of a patch part's name is the highest data version it patches): a patch the base parts have already been mutated past - which is what
APPLY PATCHESdoes - is no reason to refuse anything, so the documented migration path works as soon as the patches are applied.Closes: #118599
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
ALTER TABLE ... FETCH PARTITION/FETCH PARTno longer produces a copy that silently lacks the acknowledged lightweightUPDATEs of the source: it refuses a source partition with unapplied patch parts and asks forAPPLY PATCHES, as the other part-relocation commands already do.Workflow [PR]
Sync PR [sync-upstream/pr/119181]
Version info
26.11.1.987-master(included in26.11and later)