Repository navigation
Default insert_deduplication_version to new_unified_hash - #107886
Conversation
…ied_hash Advance the second phase of the insert deduplication hash migration. The default server setting moves from `compatible_double_hashes` to `new_unified_hash`, so ClickHouse uses a single unified deduplication hash for both sync and async inserts by default. Instances upgraded directly from `old_separate_hashes` should still run with `compatible_double_hashes` for some time (see `replicated_deduplication_window` / `non_replicated_deduplication_window`) before relying on the unified hash. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [9a5edf2] Summary: ❌
AI ReviewSummaryThis PR flips the default Final VerdictStatus: ✅ Approve |
Regenerated reference files for the deduplication tests affected by the default of insert_deduplication_version moving to new_unified_hash. None of these tests set the setting explicitly, so they observe the new default: sync and async inserts now share a single unified deduplication hash, and the old per-type async self-deduplication no longer applies. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
It waits #107915 |
…fault" This reverts commit 36d9384. The reference changes are regenerated after the unified deduplication hash fix in #107915 lands, so that only the genuinely intended changes remain (the async tests pass the original references once the hash is fixed). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…a/insert-dedup-default-new-unified-hash
01781_merge_tree_deduplication, 03008_deduplication_cases_from_docs and 03008_deduplication_insert_into_partitioned_table now reflect new_unified_hash behaviour: the non-replicated deduplication window is no longer halved (one id per insert), and deduplication is per insert, so different inserts that share a partition's content are not cross-deduplicated. Also update the now-inaccurate message in 03008_deduplication_insert_into_partitioned_table. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…p-default-new-unified-hash
Flipping the default to new_unified_hash changes the test-server behavior: deduplication entries are written only to /deduplication_hashes, not /blocks. - 00953: drop the /blocks cleanup waits (that znode is no longer written) and fix the stale comment; keep the /deduplication_hashes waits. - 01158_zookeeper_log_long: regenerate the reference (the /blocks Create/Check operations are gone; only the unified /deduplication_hashes znode remains). - 03711_deduplication_blocks_part_log: regenerate the reference (each part now records the single unified block id instead of the old+unified pair). Co-Authored-By: Claude Opus 4.8 <[email protected]>
- insert_deduplication_version: reword the stale old_separate_hashes line (no longer the recommended default) and state that new_unified_hash keys deduplication on the whole inserted block (per insert, not per partition). - insert_deduplication_token: the note claimed partition-level dedup "the same as the checksum"; under the new default the no-token checksum is over the whole inserted block, so correct the note accordingly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two more tests assumed the legacy /blocks znode (flagged by the AI review): - 01650_drop_part_and_deduplication_zookeeper_long: reworked to exercise the DROP PART + deduplication interaction under per-insert semantics. An identical retry is fully deduplicated; DROP PART removes that partition's deduplication_hashes entry; a following retry re-creates only the dropped partition while the others stay deduplicated. Reference regenerated. - test_extreme_deduplication: wait on the deduplication_hashes znode (not /blocks) for the dedup-window cleanup. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Three more tests assumed the legacy per-part sync hash: - 00215_primary_key_order_zookeeper_long: the six reordered inserts of the same values no longer collapse (the unified hash is over the source block, like async -- order-sensitive), so the reference now has all 18 rows. Regenerated. - 03711_merge_tree_deduplication_with_disk...append: identical single-row re-inserts within the window now deduplicate (the unified content hash catches retries the old sync path missed). Regenerated. - 04005_dedup_cleanup_consistent_across_directories: drop the /blocks cleanup waits (only deduplication_hashes is written now) and reword the preamble; its dual-directory regression scenario cannot occur with a single directory. Co-Authored-By: Claude Opus 4.8 <[email protected]>
03008_deduplication.python computed the insert_unique_blocks=False expected counts from the old per-part hash, where N identical blocks in one insert collapsed to one. Under new_unified_hash those blocks are kept (distinct source numbers), so the no-token case now matches the token branch -- collapse the two. Regenerate the six dedicated per-scenario references with the new counts; all 64 combos pass in insert_several_blocks / mv_generates_several_blocks / several_mv_into_one_table (replicated and non-replicated). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Under the new default, async inserts write dedup ids to the unified deduplication_hashes directory (cleaned by replicated_deduplication_window / _seconds), not the legacy async_blocks. The *_for_async_inserts window settings therefore apply only to old_separate_hashes / compatible_double_hashes: - mark those two settings legacy in their docs, - note the async behavior in the insert_deduplication_version description, - adapt 02515_cleanup_async_insert_block_ids to wait on deduplication_hashes under the sync window (verified [ OK ]). Co-Authored-By: Claude Opus 4.8 <[email protected]>
04005 was reworked for the new default new_unified_hash (single deduplication_hashes directory), dropping coverage of the dual-directory cleanup under compatible_double_hashes (legacy blocks + unified deduplication_hashes cleaned together). compatible_double_hashes is still a supported migration mode selectable only via a server setting, so move that invariant to an integration test on node_compatible: sync inserts populate both directories and the cleanup thread trims them to replicated_deduplication_window consistently. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The direct-upgrade guidance for insert_deduplication_version mentioned only the sync and non-replicated windows. Pre-upgrade async-insert ids live in async_blocks and expire by replicated_deduplication_window[_seconds]_for_async_inserts (default one week), which new_unified_hash does not consult. Running compatible_double_hashes for only the sync window before switching to new_unified_hash could therefore accept retries of pre-upgrade async inserts as duplicates. Tell users to wait for the longest relevant window (sync, async, non-replicated) before relying on the unified hash. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: This PR only changes insert-side deduplication: it flips the default insert_deduplication_version from compatible_double_hashes to new_unified_hash and updates the ReplicatedMergeTree/SharedMergeTree insert sinks, settings docs, and tests. ClickBench Q4 (-14.8%) and Q15 (-18.3%) are read-only SELECT queries against an already-loaded dataset, so they never exercise the modified insert path. Both flagged improvements are off-path and consistent with run-to-run variance on a smaller source sample (6 runs vs 30), so we downgraded them to not-sure rather than crediting the PR. No real query-execution change is expected from this default flip. 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
|
…unified_hash Under the new default insert_deduplication_version=new_unified_hash, deduplication is keyed by the insert source, so 02434_cancel_insert_when_client_dies (which inserted the same data through several sources expecting them all to cross-deduplicate) no longer holds its 500000-row invariant. Split it so each source is exercised by its own test, where same-source cancelled-and-retried inserts still deduplicate: - 02434: direct inserts into the table (native / HTTP / HTTP chunked, which share a source id), - 04365: distributed-table inserts (distributed_foreground_insert for a consistent row count), - 04366: INSERT SELECT from an uploaded file, with ORDER BY for deterministic block order. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The direct-upgrade note said pre-upgrade retries "can be accepted as duplicates", which reads as if deduplication happened. Under new_unified_hash the old blocks / async_blocks ids are not consulted, so such a retry is accepted as a new insert and produces duplicate rows. Reword accordingly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ied_hash The setting's description still documented the legacy per-created-part checksum, inconsistent with the default new_unified_hash (whole inserted block, per-insert dedup) that the async-insert note points users to. Describe the default behavior and mention the per-created-part hash only for old_separate_hashes / compatible_double_hashes. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…unified_hash Like replicated_deduplication_window, the non-replicated setting's description still referred to per-created-part hash sums. Note that its deduplication granularity follows insert_deduplication_version the same way (whole inserted block under the default new_unified_hash, per created part under the legacy versions), as for replicated tables. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Under compatible_double_hashes an async insert's deduplication_hashes id expires at the sync window while its async_blocks id persists for the async window, so its dedup effectively spans the async window. Switching to new_unified_hash (which consults only deduplication_hashes) drops that to the sync window, re-exposing async inserts older than the sync window. Document the mitigations (raise the sync window, quiesce, or stay compatible) in the migration note. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…e_hashes test_parallel_replicas_protocol builds a 3-replica ReplicatedMergeTree from two old (24.3) nodes and one new node, each inserting the same data and relying on insert deduplication to keep a single copy. Under the new default insert_deduplication_version=new_unified_hash the new node writes only the unified hash and no longer cross-deduplicates with the old replicas' legacy hash, so the table gets a second copy and sum(a) doubles. Pin the new node to compatible_double_hashes (the mixed-version migration setting) so it writes the legacy hash too and deduplicates against the 24.3 replicas. Co-Authored-By: Claude Opus 4.8 <[email protected]>
04204 Part 2 distinguished the async insert path from the sync path through the legacy per-source async window (replicated_deduplication_window_for_async_inserts). Under the new default new_unified_hash both paths share the sync window, so the parity check holds (6 == 6) even if the Alias sink drops async_insert, and the regression is no longer caught. Add an integration test on node_compatible (pinned to compatible_double_hashes) that replicates the direct-vs-Alias async-window parity, restoring the discriminating coverage under the legacy window. Note the limitation in 04204. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 78/78 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 6 line(s) · Uncovered code |
The `insert_deduplication_version` migration is complete — `new_unified_hash` became the default in ClickHouse#107886. As the first step of removing the setting and its alternatives, `DeduplicationInfo` now always computes the unified deduplication hash. Drop the `unification_stage` (`InsertDeduplicationVersions`) parameter from `DeduplicationInfo::create` and `AddDeduplicationInfoTransform`, and remove the unreachable old per-block hash path (`getBlockHash`). The call sites in `InterpreterInsertQuery`, `AsynchronousInsertQueue` and `ObjectStorageQueueSource` no longer read the server setting for this. No behaviour change under the `new_unified_hash` default: only the `old_separate_hashes` / `compatible_double_hashes` paths are removed. The setting and the `InsertDeduplicationVersions` enum remain for now (still used by `ReplicatedMergeTreeSink` and `ReplicatedMergeTreeRestartingThread`) and are removed in follow-up commits.
…edup-default-new-unified-hash Default insert_deduplication_version to new_unified_hash
The `insert_deduplication_version` migration is complete — `new_unified_hash` became the default in ClickHouse#107886. As the first step of removing the setting and its alternatives, `DeduplicationInfo` now always computes the unified deduplication hash. Drop the `unification_stage` (`InsertDeduplicationVersions`) parameter from `DeduplicationInfo::create` and `AddDeduplicationInfoTransform`, and remove the unreachable old per-block hash path (`getBlockHash`). The call sites in `InterpreterInsertQuery`, `AsynchronousInsertQueue` and `ObjectStorageQueueSource` no longer read the server setting for this. No behaviour change under the `new_unified_hash` default: only the `old_separate_hashes` / `compatible_double_hashes` paths are removed. The setting and the `InsertDeduplicationVersions` enum remain for now (still used by `ReplicatedMergeTreeSink` and `ReplicatedMergeTreeRestartingThread`) and are removed in follow-up commits.
Advances the second (final) phase of the insert deduplication hash migration introduced by #95409: the default of the server setting
insert_deduplication_versionchanges fromcompatible_double_hashestonew_unified_hash, so a single unified deduplication hash is used for both sync and async inserts.Backward-incompatible change to deduplication semantics. The unified hash is computed over the whole inserted block (the source insert, before partition splitting), so insert deduplication now works per insert, not per part/partition. Versus the previous default:
deduplication_hashesdirectory and the sync deduplication window (replicated_deduplication_window/replicated_deduplication_window_seconds, default 1 hour) instead of the separateasync_blocksdirectory;replicated_deduplication_window_for_async_inserts/…_seconds_for_async_inserts(default 1 week) no longer apply, so the default async-dedup retention window changes from 1 week to 1 hour.Set
insert_deduplication_version = compatible_double_hashesto keep the previous per-part behavior.Instances upgrading from the previous release default
compatible_double_hasheswere already writing and checking the unified hash, so for sync inserts this only stops writing the redundant old per-type hash. Async workloads need more care: undercompatible_double_hashesan async insert's id stays inasync_blocksfor the async window (default one week) while itsdeduplication_hashesid expires after the sync window (default one hour), andnew_unified_hashstops checkingasync_blocks— so before switching async workloads, raisereplicated_deduplication_window/replicated_deduplication_window_secondsto the async window and run a full async window, quiesce async inserts for that window, or stay oncompatible_double_hashes. Instances upgrading directly fromold_separate_hashesshould run withcompatible_double_hashesfor some time (seereplicated_deduplication_window/non_replicated_deduplication_window) before relying on the unified hash.Related: #95409
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The default of the server setting
insert_deduplication_versionchanges fromcompatible_double_hashestonew_unified_hash. Insert deduplication now works on the whole inserted block (per insert) rather than per part/partition: a retry of the same insert is still deduplicated, but two different inserts that produce an identical part are no longer cross-deduplicated, and reordered inserts of the same rows are no longer deduplicated. Setinsert_deduplication_version = compatible_double_hashesto restore the previous behavior. Async-insert deduplication is also governed by the sync window undernew_unified_hash: both whether it is enabled (replicated_deduplication_window) and its retention (replicated_deduplication_window_seconds, default 1 hour) follow the sync settings, so*_for_async_insertsis legacy and applies only toold_separate_hashes/compatible_double_hashes. Instances upgrading directly from a release that defaulted toold_separate_hashesshould first run withcompatible_double_hashesuntil the longest relevant deduplication window has elapsed (includingreplicated_deduplication_window_for_async_inserts, default one week, if async inserts are used) before relying onnew_unified_hash. Async workloads switching fromcompatible_double_hashesshould first raisereplicated_deduplication_window[_seconds]to the async window (and run a full async window), quiesce async inserts, or stay oncompatible_double_hashes, becausenew_unified_hashno longer checks the longer-livedasync_blocksids.🤖 Generated with Claude Code