Repository navigation
Fix outdated data parts resurrection caused by incorrectly cleaning up empty covering parts - #98698
Merged
alexey-milovidov merged 4 commits intoMar 15, 2026
Conversation
Contributor
tavplubix
approved these changes
Mar 5, 2026
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 80.00% (8/10) |
tiandiwonder
enabled auto-merge
March 11, 2026 23:43
alexey-milovidov
disabled auto-merge
March 15, 2026 02:35
alexey-milovidov
added a commit
that referenced
this pull request
Mar 27, 2026
The test relies on precise empty parts cleanup lifecycle. The random DETACH/ATTACH from PR #96130 interferes because after reattachment, `outdated_data_parts_loading_finished` is temporarily false, which blocks `clearEmptyParts` (guard from PR #98698), preventing timely cleanup and potentially resurrecting outdated parts. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=b69a3125f0167db133946240e9b08d368c9c842a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov
added a commit
that referenced
this pull request
Mar 27, 2026
The test relies on precise empty parts cleanup lifecycle. The random DETACH/ATTACH interferes because after reattachment, `outdated_data_parts_loading_finished` is temporarily false, which blocks `clearEmptyParts` (guard from PR #98698), preventing timely cleanup and potentially resurrecting outdated parts. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=b69a3125f0167db133946240e9b08d368c9c842a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
The test relies on precise empty parts cleanup lifecycle. The random DETACH/ATTACH from PR ClickHouse#96130 interferes because after reattachment, `outdated_data_parts_loading_finished` is temporarily false, which blocks `clearEmptyParts` (guard from PR ClickHouse#98698), preventing timely cleanup and potentially resurrecting outdated parts. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=b69a3125f0167db133946240e9b08d368c9c842a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
The test relies on precise empty parts cleanup lifecycle. The random DETACH/ATTACH interferes because after reattachment, `outdated_data_parts_loading_finished` is temporarily false, which blocks `clearEmptyParts` (guard from PR ClickHouse#98698), preventing timely cleanup and potentially resurrecting outdated parts. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=b69a3125f0167db133946240e9b08d368c9c842a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This was referenced Oct 27, 2026
GSokol
pushed a commit
to GSokol/ClickHouse
that referenced
this pull request
Oct 28, 2026
…etree `ALTER TABLE ... DETACH PARTITION 1` covers the inserted part with a new empty part `1_1_1_1`. It is built from the covered part's columns, so it still has column `c` (the test drops `c` only afterwards). `clearEmptyParts` outdates it in memory only, and it stays on disk for `old_parts_lifetime` (480 s). Every `local_query` is a separate `clickhouse-local` process over the same path, and each one loads `1_1_1_1` as an active part again. At startup `clearEmptyParts` hides it, but not while outdated parts are still loading asynchronously (the guard from ClickHouse#98698). The `DELETE` leaves the outdated `1_3_3_0` on disk, so from then on every process keeps `1_1_1_1` active until the pending mutations rewrite it in the background. When that rewrite has not committed before the `system.parts_columns` query, the query sees `c` and the test prints `the rewrite dropped the column: 1` (seen in `Stateless tests (arm_binary, parallel)` and `Fast test`). Set `old_parts_lifetime = 0` for the test table, so the empty part is removed from disk inside the `DETACH PARTITION` statement and no later process can load it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix outdated data parts resurrection caused by incorrectly cleaning up empty covering parts.
Documentation entry for user-facing changes
Note
Medium Risk
Touches MergeTree part cleanup during startup/attach; while the change is small, it affects data-part lifecycle ordering and could impact correctness if the loading state is mis-signaled.
Overview
Prevents
MergeTreeData::clearEmptyParts()from removing empty covering parts until asynchronous outdated-part loading has finished, avoiding cases where covered outdated parts can later resurrect as active afterDETACH/ATTACHor restart.Updates existing stateless tests to ignore timing-dependent empty parts and adds a regression test (
04007_truncate_empty_parts_detach_attach.sh) that reproduces the TRUNCATE→DETACH/ATTACH “zombie parts” scenario.Written by Cursor Bugbot for commit b43ca3c. This will update automatically on new commits. Configure here.
Version info
26.3.1.675