Repository navigation
Fix inconsistent deduplication block cleanup ordering - #98293
Merged
Merged
Conversation
With `COMPATIBLE_DOUBLE_HASHES` (the default `insert_deduplication_version`), each insert creates entries in both `blocks/` and `deduplication_hashes/` ZooKeeper directories with different node names (SYNC hash vs UNIFIED/SipHash). The cleanup thread sorts blocks by `(ctime, node_name)` descending and removes the oldest entries beyond the deduplication window. When multiple entries have equal ctimes, the node name tiebreaker can produce different sort orders in `blocks/` vs `deduplication_hashes/` because the hash algorithms yield different names. This causes different logical inserts to be removed from each directory, and the union of remaining entries can cover all original hashes, making all re-inserts appear as duplicates. Fix by using `czxid` (creation transaction ID) instead of node name as the sort tiebreaker. Entries created in the same ZooKeeper multi-op (same logical insert) share the same `czxid`, ensuring consistent ordering across both directories. Closes #98123 https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96351&sha=82aad167343abbf730a07809b553b3b029d62d52&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
…ctories The test verifies that cleanup of `blocks/` and `deduplication_hashes/` ZooKeeper directories removes entries for the same logical inserts. Unlike the existing test `00953`, this test waits for cleanup of BOTH directories before re-inserting, which catches the case where inconsistent ordering causes different entries to be removed from each directory. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The style check requires `$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX` or `{database}`
to appear directly in the `ReplicatedMergeTree(...)` constructor call.
Using an intermediate variable caused the check to fail.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Fix `04005_dedup_cleanup_consistent_across_directories`: add missing `/clickhouse/tables/` prefix to ZooKeeper path (was causing "ZooKeeper path must starts with '/'" errors in CI). - Fix `00953_zookeeper_suetin_deduplication_bug`: wait for BOTH `blocks/` and `deduplication_hashes/` directories to be cleaned up, not just `blocks/`. With `COMPATIBLE_DOUBLE_HASHES` (default), each insert creates entries in both directories. The cleanup thread processes them sequentially, so an insert between the two cleanups can leave `deduplication_hashes/` with stale entries while `blocks/` is already cleaned, causing re-inserts to be incorrectly deduplicated. Co-Authored-By: Claude Opus 4.6 <[email protected]>
CheSema
approved these changes
Mar 2, 2026
CheSema
left a comment
Member
There was a problem hiding this comment.
Thanks, I should have done this in my PR but it had not been triggered there, so I missed it.
This was referenced Apr 8, 2026
Merged
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.
Summary
00953_zookeeper_suetin_deduplication_bugcaused by inconsistent deduplication block cleanup ordering acrossblocks/anddeduplication_hashes/ZooKeeper directoriesCOMPATIBLE_DOUBLE_HASHES(default), each insert creates entries in both directories with different node names (SYNC hash vs UNIFIED/SipHash). The cleanup sort comparator used(ctime, node_name)as tiebreaker, which can produce different sort orders across directories when ctimes are equal, causing different logical inserts to be removed from each directoryczxid(ZooKeeper creation transaction ID), which is the same for entries created in the same multi-op, ensuring both directories remove entries for the same logical insertsCloses #98123
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96351&sha=82aad167343abbf730a07809b553b3b029d62d52&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29
#96351
Test plan
00953_zookeeper_suetin_deduplication_bugshould pass consistentlyChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix sporadic deduplication failure where re-inserts were incorrectly deduplicated due to inconsistent cleanup ordering between
blocks/anddeduplication_hashes/ZooKeeper directories.🤖 Generated with Claude Code
Version info
26.3.1.277