Repository navigation
Do not deduplicate restored ReplicatedMergeTree parts - #107652
Conversation
`RESTORE` attaches restored parts through the same existing-part sink path as `ATTACH`. That path applies insert deduplication, so duplicate-content parts from a backup can be silently dropped during restore. Keep the default behavior for `ATTACH`, but disable part deduplication for restored parts. Add a deterministic backup/restore regression test for duplicate parts.
|
Workflow [PR], commit [9f1f8af] Summary: ✅
AI ReviewSummaryThis PR disables insert deduplication only for restored Final VerdictStatus: ✅ Approve |
There was a problem hiding this comment.
Pull request overview
Fixes RESTORE for ReplicatedMergeTree to avoid insert-deduplication being applied while attaching parts from a backup, which could previously drop duplicate-content parts and lose rows during restore.
Changes:
- Disable part deduplication when attaching restored parts by passing an explicit
deduplicate_part = falseflag. - Extend
ReplicatedMergeTreeSink::writeExistingPartwith an optionaldeduplicate_partparameter (default keeps existingATTACHbehavior). - Add an integration test that reproduces the row-loss scenario with duplicate-content parts and verifies both replicas restore all rows.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/integration/test_backup_restore_on_cluster/test.py | Adds a regression integration test ensuring restored duplicate-content parts are preserved. |
| src/Storages/StorageReplicatedMergeTree.cpp | Wires restored-part attachment to skip deduplication (deduplicate_part = false). |
| src/Storages/MergeTree/ReplicatedMergeTreeSink.h | Updates the sink API to accept an optional deduplicate_part flag (default true). |
| src/Storages/MergeTree/ReplicatedMergeTreeSink.cpp | Gates existing-part deduplication on deduplicate_part to avoid dropping duplicate restored parts. |
Use a single expected aggregate from `node1` instead of comparing restored data against each replica's local source table. This avoids depending on whether the source table has already replicated to `node2` while still checking restored data on both replicas.
Drop `tbl` and `tbl2` on `cluster` from the regression test itself. The module fixture only cleans `cluster3`, so the test must clean objects it creates on `cluster` to avoid leaking stopped-merge state or table names into later tests.
|
📊 Cloud Performance Report ✅ AI verdict: This PR only changes the INSERT/ATTACH/RESTORE deduplication write path (adding a deduplicate_part flag so RESTORE preserves duplicate parts) plus integration tests — it does not touch any SELECT query-execution code. The two flagged ClickBench improvements (Q4 -11.85%, Q15 -11.6%) are read-only SELECT queries that never exercise the modified code, so these deltas cannot be a real effect of this change and are downgraded to not-sure. Both queries also carry a trending history signal, which is consistent with these shifts being run-to-run variance rather than a PR-driven speedup. No genuine performance change attributable to this PR. clickbenchFlagged queries (2 of 43)
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
|
pamarcos
left a comment
There was a problem hiding this comment.
Publishing addressed review replies.
Cherry pick #107652 to 26.4: Do not deduplicate restored ReplicatedMergeTree parts
Cherry pick #107652 to 26.5: Do not deduplicate restored ReplicatedMergeTree parts
Cherry pick #107652 to 26.6: Do not deduplicate restored ReplicatedMergeTree parts
Resolve the `ReplicatedMergeTreeSink` conflict from master's "do not deduplicate restored ReplicatedMergeTree parts" change (#107652): keep the new `deduplicate_part` gate but compute only the unified hash, since this PR removes the per-version deduplication switch. Renumber `04411_storage_alias_async_insert_dedup` to `04413` off master's new `04411_planner_actions_visitor_shared_subexpr_reuse`.
Cherry pick #107652 to 25.8: Do not deduplicate restored ReplicatedMergeTree parts
Backport #107652 to 26.6: Do not deduplicate restored ReplicatedMergeTree parts
Backport #107652 to 26.3: Do not deduplicate restored ReplicatedMergeTree parts
Backport #107652 to 25.8: Do not deduplicate restored ReplicatedMergeTree parts
Backport #107652 to 26.5: Do not deduplicate restored ReplicatedMergeTree parts
Backport #107652 to 26.4: Do not deduplicate restored ReplicatedMergeTree parts
…dedup-rmt Do not deduplicate restored ReplicatedMergeTree parts
Resolve the `ReplicatedMergeTreeSink` conflict from master's "do not deduplicate restored ReplicatedMergeTree parts" change (ClickHouse#107652): keep the new `deduplicate_part` gate but compute only the unified hash, since this PR removes the per-version deduplication switch. Renumber `04411_storage_alias_async_insert_dedup` to `04413` off master's new `04411_planner_actions_visitor_shared_subexpr_reuse`.
Restoring
ReplicatedMergeTreetables attaches restored parts through the same existing-part sink path asATTACH.That path applies insert deduplication, so a backup containing multiple duplicate-content parts can be restored with missing rows.
This change preserves the default deduplication behavior for
ATTACH, but disables part deduplication when restored parts are attached from a backup.A deterministic integration test covers duplicate restored parts and fails on
26.4.2.10with the restored table containing one row instead of two.Closes: https://github.com/ClickHouse/clickhouse-private/issues/61121
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
RESTOREforReplicatedMergeTreetables so duplicate-content parts from a backup are preserved instead of being silently deduplicated.Documentation entry:
Version info
26.7.1.117(included in26.7and later)26.6.2.3,26.5.4.23,26.4.5.79,26.3.16.14,25.8.25.37