Repository navigation
Sync Introduce Invalidated System Columns - #111801
Conversation
|
Workflow [PR], commit [b6c3333] Summary: ❌
AI ReviewSummaryThis PR introduces PR Metadata
Findings❌ Blockers
Tests
Final Verdict
|
|
No need to review. Changes were reviewed in the private repo. |
| bool make_source_readonly = false; | ||
| DiskTransactionPtr external_transaction = nullptr; | ||
| std::optional<int32_t> metadata_version_to_write = std::nullopt; | ||
| NameSet invalidated_columns_to_write = {}; |
There was a problem hiding this comment.
This new field defaults to an empty set, but freeze / freezeRemote now always rewrite invalidated_system_columns.txt. That means any clone caller that still uses the default does not preserve the source part's invalidation marker; it actively clears it in the clone.
There are already such callers in the current tree (MutateTask's !any_rows_affected fast path, StorageReplicatedMergeTree's local-clone fetch shortcut, FREEZE). If one of those paths clones a part that was invalidated by ATTACH / MOVE / REPLACE, the new part falls back to the stale persisted _block_number / _block_offset files again.
Can this default be changed to "preserve the source marker unless the caller explicitly overrides it", or can those clone callers be updated in the same patch?
| && name == IMergeTreeDataPart::COLUMNS_SUBSTREAMS_FILE_NAME) | ||
| continue; | ||
|
|
||
| if (client_protocol_version < REPLICATION_PROTOCOL_VERSION_WITH_INVALIDATED_SYSTEM_COLUMNS |
There was a problem hiding this comment.
Skipping invalidated_system_columns.txt for older replication-protocol peers is not just feature loss: it drops the only metadata that tells the receiver the stored _block_number / _block_offset files are stale.
During a rolling upgrade, a new replica can create an invalidated part (for example via ATTACH / MOVE / REPLACE) and an older replica will accept the transferred part without that marker, so the two replicas can return different _block_number / _block_offset values and may also reuse stale projections / skip indices built on them.
This needs a fail-closed behavior for old peers: either reject transferring such parts to them, or materialize fresh system-column files when talking to an older protocol version.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 260/283 (91.87%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This sync PR reworks MergeTree part-storage plumbing for invalidated system columns (block number/offset persistence, projection rebuilds on merge, and the index getDeserializedFormat signature) — none of which the read-only ClickBench SELECT hot path executes. Both flagged items are improvements, not regressions, and neither aligns with the diff: Q4's -25.5% falls inside master's own variance band [201-293.5 ms] and was correctly suppressed, while Q15's -14.8% is downgraded to not_sure as run-to-run noise. No credible performance change is attributable to this PR. clickbenchFlagged queries (1 of 43)
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. tpch_adapted_1_official🟢 No significant changes Debug info
|
Update to latest master (9125947, 86 commits since the previous merge). Conflicts, all from #111801 (Invalidated System Columns): fold writeInvalidatedSystemColumnsFile into the redesigned unified freeze in DataPartStorageOnDiskBase and DataPartStorageOnDiskPacked, and add the block-number/block-offset invalidation skip to the redesigned loadProjections in IMergeTreeDataPart. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A clone of a part that passes no invalidated_columns_to_write (the untouched-part clone in a mutation, clone-instead-of-fetch of a replicated mutation, moves between disks) used to delete the invalidated_system_columns.txt it had just hardlinked or copied from the source part: writeInvalidatedSystemColumnsFileImpl unconditionally removed the existing file and wrote nothing back for an empty set. Losing the file resurrects the stale physically stored _block_number and _block_offset values that were disclaimed when the part was adopted from another table (ClickHouse#111801), so several co-active clones of one source part expose duplicate row identities. A lightweight UPDATE then captures the duplicates into a single patch part with a constant _part_data_version, and applying that patch in Join mode fails the 'current_version != existing_version' assertion in PatchJoinCache::Entry::addBlock, which aborts debug and sanitizer builds; release builds silently drop one of the duplicate rows. Fix in two places: - writeInvalidatedSystemColumnsFileImpl keeps an existing file when the caller has nothing new to invalidate; this covers the clones that copy or hardlink the whole part directory. - cloneAndLoadDataPart merges the source part's invalidated set into the clone parameters; this also covers the Packed storage, whose freeze/freezeRemote copy only the data archive, so the destination never inherits the file. Failure history: https://play.clickhouse.com/play?user=play&tab=Query%20V#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIHB1bGxfcmVxdWVzdF9udW1iZXIsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSBGUk9NIGNoZWNrcwpXSEVSRSB0ZXN0X25hbWUgTElLRSAnJWN1cnJlbnRfdmVyc2lvbiAhPSBleGlzdGluZ192ZXJzaW9uJScgQU5EIGNoZWNrX3N0YXJ0X3RpbWUgPj0gbm93KCkgLSBJTlRFUlZBTCAzIE1PTlRICk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWU= The reproduced CI failure (the only one on a branch that already had the invalidation mechanism from ClickHouse#111801): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113029&sha=cebdc42b01538df822d2da154bb5b51f1d4538d6&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29 ClickHouse#113029 Co-Authored-By: Claude Fable 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
During attach/detach/move/clone part manipulations, materialized into part
block_numberandblock_offsetbecome stale. This patch changes the behavior to regenerate these columns.Fix is implemented as a materialization of an additional file,
invalidated_system_columns.txt, which will not be included in packed/compact archives and will be written during attach/clone partition operations.