Repository navigation
Write the empty covering part before removing the covered parts - #122610
Conversation
`removePartsInRangeFromWorkingSetAndGetPartsToRemoveFromZooKeeper` removed the parts in the drop range from the working set first, and only then wrote the empty covering part with `createEmptyPart`. When writing that part threw (in CI: a `MEMORY_LIMIT_EXCEEDED` fault injected by the stress run), the parts were already outdated but no covering part existed. The following `REPLACE_RANGE` then found no active parts, skipped the covering part, and removed the parts from ZooKeeper only. They stayed on disk and on the next table load were reported as uncovered unexpected parts (`TOO_MANY_UNEXPECTED_DATA_PARTS`), leaving the table readonly. Write the covering part first, so a failure leaves the working set unchanged, and only activate it after the removal (`renameTempPartAndAdd` requires the covered parts to be gone). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121145&sha=9a11b79684ac15a56bd16ef7491a5040688a8f7b&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 PR: #121145 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Workflow [PR], commit [55cbede] Summary: ✅
AI ReviewSummaryThis PR moves empty covering-part creation ahead of removing the covered parts, adds explicit Final Verdict
LLVM Coverage ReportMeasured on commit 55cbede.
Changed lines: Changed C/C++ lines covered: 27/44 (61.36%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units283 translation units recompiled, 2877 s compile time in total, 283 of them have a recent master baseline. |
Address review: #122610 (comment) The empty covering part is now written before the covered parts leave the working set. If `removePartsFromWorkingSet`, `renameTempPartAndAdd` or `commitTransaction` throws in between, the part storage transaction stays uncommitted. On object storage the part directory does not exist until the commit, so the destructor of the temporary part removes nothing, and the uploaded blobs are stranded. Undo the transaction (best-effort) on that path. `undoTransaction` existed only in the `CLICKHOUSE_CLOUD` build; it is promoted to `IDataPartStorage` and implemented for `DataPartStorageOnDiskFull` and `DataPartStorageOnDiskPacked`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
📊 Cloud Performance Report
This PR has no measurable effect on query performance. It changes how MergeTree writes and rolls back the empty covering part during DROP/REPLACE PARTITION, and it makes undoTransaction available on non-cloud builds too. None of the benchmarked SELECT queries run that code. The only two flagged queries are tpch_adapted_1_official Q1 (-18.5%) and Q7 (-16.0%). Both stay not_sure because master's own timings for them shifted recently, so the baseline can't support attribution, and both have noisy history. Neither delta should be read as an improvement from this PR. clickbench🟢 No significant changes tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
`DataPartStorageOnDiskPacked::commitTransaction` committed the disk transaction and only then loaded the reader, still holding the committed transaction. If loading the reader threw, the caller's undo guard in `removePartsInRangeFromWorkingSet` would call `undoTransaction`, which removes the written blobs while their metadata is already committed, leaving a committed empty covering part without its data. Reset the transaction right after the commit, so `undoTransaction` is a no-op past the point of no return. Do the same in `tryCommitTransaction`. Addresses review: #122610 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
This looks good.
|
@alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
removePartsInRangeFromWorkingSetAndGetPartsToRemoveFromZooKeeperremoved the parts of the drop range from the working set before writing the empty covering part. IfcreateEmptyPartthrew (here: aMEMORY_LIMIT_EXCEEDEDfault injected during the stress phase of the Upgrade check), the parts were already outdated with no covering part. The queuedREPLACE_RANGEthen saw no active parts ("Replacing 2 parts ... with empty set"), skipped the covering part becauseparts_to_removewas empty, and removed the parts from ZooKeeper only. They stayed on disk, and the next load of the table (02486_truncate_and_unexpected_parts, withreplicated_max_ratio_of_wrong_parts = 0) failed withTOO_MANY_UNEXPECTED_DATA_PARTSand left it readonly.The fix writes the covering part before the removal, so a failure leaves the working set unchanged. The part is activated after the removal, because
renameTempPartAndAddrequires the covered parts to be gone.There is no deterministic test: the failure needs an exception at exactly this point.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121145&sha=9a11b79684ac15a56bd16ef7491a5040688a8f7b&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
Related: #121145
Related: #120980
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122610]
Version info
26.10.1.1370-master(included in26.10and later)