Skip to content

Revert "Answer sum, avg and sumCount from per-part statistics" - #130674

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/revert-123950
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/revert-123950

Conversation

@groeneai

@groeneai groeneai commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Reverts #123950

Related: #123950

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Description

#123950 adds the sum of the values to the basic statistics of integer and Decimal columns, which have them by default. A merge or a mutation now writes a different statistics.packed than 26.10 does, so in a mixed-version cluster a replica finds its part not byte-identical (CHECKSUM_DOESNT_MATCH), discards it and refetches it. The Upgrade check hit this in 1 of 310 runs since the merge (CI report). On parts written by 26.10.2.103, the merge commit 95d1955 and master b192835 write different bytes than 26.10.2.103, while the first parent 4e08dbd (amd_binary CI builds, 3/3 runs) and a debug build of this revert write the same bytes. A forward fix that keeps mixed-version parts identical is the alternative.

Proof

hash_of_uncompressed_files of the resulting part; only statistics.packed differs, uncompressed_hash_of_compressed_files is equal everywhere. CI reported 927af983... vs d2f18c54....

case 26.10.2.103 first parent 4e08dbd merge commit 95d1955 master b192835 this revert
Compact part, UPDATE twice 927af983 927af983 d2f18c54 d2f18c54 927af983
two Compact parts, OPTIMIZE FINAL 29efcd3e 29efcd3e 593f5629 593f5629 29efcd3e
Wide part, UPDATE twice 927af983 927af983 e2f6aff1 e2f6aff1 927af983

clickhouse local 26.10.2.103 creates d.r (k UInt64, v UInt64) ENGINE = MergeTree ORDER BY k (Wide: min_bytes_for_wide_part = 0, min_rows_for_wide_part = 0), inserts (1, 1) and runs ALTER TABLE d.r UPDATE v = 2 WHERE 1 (merge case: SYSTEM STOP MERGES, inserts (1, 1) and (2, 2)). Each binary then runs UPDATE v = 3 and UPDATE v = 4 (merge case: SYSTEM START MERGES, OPTIMIZE TABLE d.r FINAL) on its own copy of the data directory.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/130674]

…rf-wins-from-lowlevel-pattern-audit-2026-09-19"

This reverts commit 95d1955, reversing
changes made to 4e08dbd.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pure-revert check

Applying the diff of #123950 (its first parent 4e08dbd to its merge commit 95d1955) on top of this commit gives exactly the tree of the master commit it is based on, so this PR is #123950 reversed with no other change.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov, could you review this? This reverts #123950, whose sum in basic statistics makes merges and mutations write different statistics.packed bytes than 26.10, so mixed-version replicas refetch parts: 26.10 and 4e08dbd write the same bytes, 95d1955 does not.

@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fc37435]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog can be tested Allows running workflows for external contributors comp-skip-index Skipping indexes (minmax, set, bloom) and their evaluation. labels Nov 11, 2026
@NIKTONIKTO717 NIKTONIKTO717 self-assigned this Nov 11, 2026

@ch-samuel-reviewer-1 ch-samuel-reviewer-1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai, thanks for the measurements, they are right: a 26.11 replica writes statistics.packed with the sum and a 26.10 replica writes it without, so when both execute the same merge or mutation, the replica that commits second gets CHECKSUM_DOESNT_MATCH and fetches the part from the other one. I don't think this is a reason to revert, though:

  1. It is the expected behavior during a rolling upgrade, not a bug. Both versions read each other's parts and return correct results: 26.10 skips the sum it does not know, and 26.11 reads parts without the sum as before. The only cost is a refetch of such parts until all replicas run 26.11. The upgrade guide describes exactly this error: "This error message is expected when there are multiple versions of ClickHouse running in a replicated environment. You will stop seeing these when all replicas are upgraded to the same version."

  2. Earlier releases did the same. 26.7 changed the default auto_statistics_types from minmax, uniq to basic, uniq_v2, so 26.6 and 26.7 replicas write different statistics.packed for the same merge or mutation of every table (checked with 26.6.8.7 and 26.7.37.6, the same steps as in your table).

  3. The revert would not make 26.11 byte-identical with 26.10 anyway. 26.11 also changes the default text_index_posting_list_codec to pfor (#127489), so merges and mutations of tables with a text index differ between 26.10 and 26.11 with or without this revert.

  4. The Upgrade check stops hitting this once 26.11 is released. The failing run is the same situation: after the upgrade, the new server executed a mutation that 26.10 had already executed on the other replica. When 26.11 becomes the previous release, both servers in the check write the sum.

So I'd prefer to keep #123950 and close this revert.

This review was checked, modified and approved by human (@NIKTONIKTO717).

@NIKTONIKTO717 NIKTONIKTO717 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai please consider arguments provided in #130674 (review) . Feel free to push back if you find sufficient evidence to do so.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks, I checked the four points and they hold: the upgrade guide documents this message as expected while replica versions differ, auto_statistics_types changed in 26.7 (I measured the same 26.6 to 26.7 statistics.packed difference in August: #103395 (comment)), and text_index_posting_list_codec changes to pfor in 26.11. I have no evidence to push back, so I'm closing this revert.

For the Upgrade check, I'll open a separate PR that ignores is not byte-identical to data on another replicas in the upgrade_runner.sh log scan, as it already ignores ILLEGAL_STATISTICS from statistics format changes between releases.

@groeneai

Copy link
Copy Markdown
Collaborator Author

I opened #130760 for the Upgrade check. It ignores the message only when the hash of uncompressed files is the sole mismatch (the documented cross-version case), which is narrower than the key I named above, so divergent column data after a replicated merge or mutation still fails the job.

alexey-milovidov pushed a commit to pugachevdmitry/ClickHouse that referenced this pull request Nov 12, 2026
…part files after the upgrade

After the restart, the upgraded server executes a MERGE_PARTS or MUTATE_PART
entry whose result the other replica already committed under the previous
release. checkPartChecksumsAndCommit compares the new part with the ZooKeeper
part header written by the old release. Releases change the byte format of
uncompressed part files: statistics.packed is registered with file_hash only,
so it lands in the "hash of uncompressed files" bucket, and its content changed
in 26.7 (auto_statistics_types default) and in 26.11 (ClickHouse#123950 adds the sum to
basic statistics). The task then logs CHECKSUM_DOESNT_MATCH at error level,
removes the local part and fetches the replica's part. The upgrade guide
(docs/guides/oss/update.mdx) documents this message as expected while replica
versions differ, and the statistics author confirmed it on ClickHouse#130674, but the
post-upgrade log scan treated it as a failure.

Filter the line only when "hash of uncompressed files doesn't match" is the
sole clause. Divergent column data ("uncompressed hash of compressed files"),
both clauses together, a different number of files and the KILL MUTATION
"different columns hash" case still fail the job. The Upgrade check is the only
CI job that reports these lines (the stress tests scan only
"<Error>.*Application"), so a broader filter on "is not byte-identical to data
on another replicas" would remove the only CI detector of divergent column data
after replicated merges and mutations.

Validated by running the extracted scan on the Upgrade check log of ClickHouse#130547
(1 line -> 0) and on 7 control lines (7 -> 5, every other shape kept), with
GNU grep 3.11 locally and inside clickhouse/stress-test. Changing "Code: 40" to
"Code: 41" in the new pattern restores both results.

Related: ClickHouse#103395
Related: ClickHouse#130674

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-statistics Column statistics: statistics kept per part on a column (tdigest, uniq, count-min sketch, minmax)... and removed comp-skip-index Skipping indexes (minmax, set, bloom) and their evaluation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-statistics Column statistics: statistics kept per part on a column (tdigest, uniq, count-min sketch, minmax)... pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants