Skip to content

Fix mutations of compact parts with statistics - #97140

Merged
CurtizJ merged 1 commit into
ClickHouse:masterfrom
CurtizJ:fix-mutations-with-statistics
Feb 17, 2026
Merged

CurtizJ merged 1 commit into
ClickHouse:masterfrom
CurtizJ:fix-mutations-with-statistics

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Feb 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Bugfix for unreleased feature.

Version info

  • Merged into: 26.2.1.834

@clickhouse-gh

clickhouse-gh Bot commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c42b6b6]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, db disk, old analyzer, 3/6) failure
test_refreshable_mv/test.py::test_backup_inner_table FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_adding_replica FAIL cidb IGNORED
Integration tests (amd_tsan, 3/6) failure
test_refreshable_mv/test.py::test_refresh_vs_shutdown_smoke FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_pause FAIL cidb, issue ISSUE EXISTS
Integration tests (amd_msan, 3/6) failure
test_refreshable_mv/test.py::test_refresh_vs_shutdown_smoke FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_pause FAIL cidb, issue ISSUE EXISTS

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Feb 17, 2026
@tiandiwonder
tiandiwonder requested a review from Copilot February 17, 2026 05:00

Copilot AI 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.

Pull request overview

This PR fixes a bug in mutations of compact parts with automatic statistics. When replicas in a ReplicatedMergeTree load metadata changes from ZooKeeper, they were not re-adding implicit statistics (defined by auto_statistics_types setting), causing mutations to produce incorrect statistics cardinality values.

Changes:

  • Fixed setTableStructure in StorageReplicatedMergeTree to re-add implicit statistics after loading metadata from ZooKeeper
  • Updated test to use compact parts (removed min_bytes_for_wide_part = 0 setting) to properly test the mutation scenario
  • Updated expected test output to reflect correct cardinality of 1 instead of incorrect value of 2

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Storages/StorageReplicatedMergeTree.cpp Added code to re-add implicit statistics after loading metadata from ZK, following the same pattern used in StorageMergeTree::alter
tests/queries/0_stateless/03919_modify_nullable_statistics.sql Removed min_bytes_for_wide_part = 0 setting to test with compact parts (default behavior)
tests/queries/0_stateless/03919_modify_nullable_statistics.reference Updated expected output to show correct cardinality of 1 after mutation

@antaljanosbenjamin antaljanosbenjamin self-assigned this Feb 17, 2026
@CurtizJ
CurtizJ added this pull request to the merge queue Feb 17, 2026
Merged via the queue into ClickHouse:master with commit eb563c7 Feb 17, 2026
146 of 149 checks passed
@CurtizJ
CurtizJ deleted the fix-mutations-with-statistics branch February 17, 2026 10:44
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants