Skip to content

Cherry pick #107915 to 26.3: Fix position-dependent column-wise insert deduplication hash - #107961

Merged
CheSema merged 7 commits into
backport/26.3/107915from
cherrypick/26.3/107915
Jun 19, 2026
Merged

CheSema merged 7 commits into
backport/26.3/107915from
cherrypick/26.3/107915

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #107915

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

CheSema and others added 6 commits June 18, 2026 23:54
ColumnString::updateHashWithValueRange and ColumnArray::updateHashWithValueRange
hashed the absolute cumulative offsets of the row range, so the hash depended on
the position of the range within the column. This function computes the
column-wise data hash used by the unified insert deduplication path
(insert_deduplication_version = new_unified_hash and compatible_double_hashes),
so two identical blocks located at different offsets - e.g. repeated rows
combined into one async insert flush - produced different deduplication block ids
and were not deduplicated. Fixed-width columns were already position-invariant.

Hash the boundaries relative to the start of the range instead. For begin == 0
(every single-block insert) the bytes fed to the hash are unchanged, so unified
deduplication ids already persisted under compatible_double_hashes stay valid;
only the broken multi-offset case changes.

Add a unit test (equal String blocks at different offsets) and an integration
test (async self-deduplication under new_unified_hash with String and Array
columns). Both fail before the fix and pass after.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… byte stream

Use the raw-byte SipHash overload for the computed relative offset instead of
SipHash::update(UInt64), which endian-normalizes the value on big-endian targets.
This keeps the begin == 0 byte stream identical to the previous absolute-offset
hashing on all architectures (including s390x), so unified deduplication ids
already persisted under compatible_double_hashes stay valid there too.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…pat note

The unified deduplication hash is not authoritative until new_unified_hash is the
default: under compatible_double_hashes the legacy id (unchanged here) provides
deduplication, so the previously-broken unified hashes do not need to be preserved.
Use the plain SipHash integer update and a clearer comment instead of the raw-byte
overload that was only there for byte-identity.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…se-hash-position

Fix position-dependent column-wise insert deduplication hash
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Jun 19, 2026
…ypick/26.3/107915

# Conflicts:
#	src/Storages/MergeTree/tests/gtest_async_inserts.cpp
@CheSema
CheSema merged commit 78d0b62 into backport/26.3/107915 Jun 19, 2026
1 check passed
@CheSema
CheSema deleted the cherrypick/26.3/107915 branch June 19, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants