Skip to content

Fix flaky test 03706_statistics_preserve_checksums_on_mutations - #101580

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix/03706-statistics-checksums-flaky
Apr 8, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix/03706-statistics-checksums-flaky

Conversation

@groeneai

@groeneai groeneai commented Apr 2, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

  • none

What this PR does

Re-adds serialization_info_version='basic' pin to the CREATE TABLE settings in test 03706_statistics_preserve_checksums_on_mutations. This pin was originally added in PR #100772 (merged 2026-03-26) which reduced failures from ~208/day to near-zero. PR #100896 (merged 2026-03-27) mistakenly replaced it with map_serialization_version pins, which address a different issue.

Root cause: When serialization_info_version='with_types' is randomized by the test runner, the INSERT and mutation (ALTER TABLE REWRITE PARTS) paths may produce different serialization.json metadata content. The with_types version includes types_serialization_versions data that can differ between the two code paths due to the tryDowngradeToBasic() logic interacting differently with randomized string_serialization_version and nullable_serialization_version values. This causes hash_of_all_files and hash_of_uncompressed_files mismatches (while uncompressed_hash_of_compressed_files stays identical — actual data is fine).

Evidence:

🤖 Generated with Claude Code

Version info

  • Merged into: 26.4.1.618
  • Backported to: 26.3.11.28

Re-add serialization_info_version='basic' pin that was mistakenly removed
in PR ClickHouse#100896. The original fix in PR ClickHouse#100772 correctly identified that
serialization_info_version='with_types' causes checksum mismatches between
INSERT and mutation paths due to different serialization.json metadata content.

PR ClickHouse#100896 replaced this pin with map_serialization_version pins, but that
addressed a different issue. After ClickHouse#100896 merged, master failures returned
at ~1-3/day (32 master failures in 14 days across all CI build types).

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

groeneai commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ — could you review this? It re-adds the serialization_info_version='basic' pin that PR #100772 originally added to fix flaky checksums, which PR #100896 mistakenly removed (replacing with map_serialization_version pins). 32 master failures in 14 days since the removal.

@groeneai

groeneai commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-PR Validation (session: cron:clickhouse-ci-task-worker:20260402-034500)

a) Deterministic repro? Partial — cannot deterministically trigger in local testing (100+ runs, 0 failures), but CI shows 32 master failures in 14 days (~11% rate across all check types). The failure requires a CI-specific combination of parallel execution + randomized serialization_info_version='with_types' + the tryDowngradeToBasic() logic interacting with other randomized serialization version settings.

b) Root cause explained? Yes — When serialization_info_version='with_types' is randomized, the SerializationInfoByName version stays at WITH_TYPES (version=1) if other type-specific settings (string_serialization_version, nullable_serialization_version) are also randomized to non-default values (preventing tryDowngradeToBasic()). This causes serialization.json to include types_serialization_versions metadata. The INSERT and mutation paths construct SerializationInfo::Settings through different code paths (MergeTreeDataWriter.cpp:810 vs MutateTask.cpp:624), with the mutation using map_serialization_version while INSERT uses map_serialization_version_for_zero_level_parts. Under specific CI conditions, this produces different serialization.json content → different file hashes → test failure.

c) Fix matches root cause? Yes — pinning serialization_info_version='basic' ensures the version is always 0, serialization.json uses the basic format, and tryDowngradeToBasic() becomes irrelevant. This was the exact fix in PR #100772 that reduced failures from ~208/day to ~0.

d) Test intent preserved? Yes — the test verifies that statistics checksums are preserved through mutation+detach/attach cycles. The serialization_info_version setting is unrelated to statistics behavior — it only affects metadata formatting. The test still fully exercises the statistics computation path.

e) Both directions demonstrated? The fix passes 50/50 locally. The "without fix" direction is demonstrated by 32 master failures in 14 days on the unfixed code, plus the historical evidence from PR #100772 (adding the pin stopped failures) → PR #100896 (removing it brought them back).

@clickhouse-gh

clickhouse-gh Bot commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e79f867]

Summary: ✅


AI Review

Summary

This PR updates one flaky test by re-adding serialization_info_version='basic' in 03706_statistics_preserve_checksums_on_mutations.sh. The change is narrowly scoped, aligns with the described root cause, and avoids checksum instability caused by metadata differences in serialization.json under randomized settings. I did not find correctness, safety, or performance issues in the patch itself.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 3, 2026
@groeneai

groeneai commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ — could you review this? It's a test-only fix for chronic flaky test 03706_statistics_preserve_checksums_on_mutations (82 PRs affected in 30d). The fix pins mutations_execute_subqueries_on_initiator=0 since the test depends on per-part mutation execution.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Apr 7, 2026
@CurtizJ CurtizJ self-assigned this Apr 7, 2026
@alexey-milovidov
alexey-milovidov merged commit 31d0d40 into ClickHouse:master Apr 8, 2026
320 of 322 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 8, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Apr 17, 2026
…reserve_checksums_on_mutations

Backport of PR ClickHouse#101580 to the 26.3 release branch.

Pins `serialization_info_version='basic'` in the test's `CREATE TABLE`
settings. The test is chronically flaky on 26.3 (25 direct-push failures
and 15 backport PR failures in the last 30 days) because CI randomizes
`serialization_info_version='with_types'`, which causes the `INSERT` and
`ALTER TABLE REWRITE PARTS` paths to produce different
`serialization.json` metadata content (different type version metadata),
resulting in `hash_of_all_files` and `hash_of_uncompressed_files`
checksum mismatches. The actual data is fine
(`uncompressed_hash_of_compressed_files` stays identical).

The equivalent pin has been in place on `master` since 2026-04-08 (PR
ClickHouse#101580 re-added it after PR ClickHouse#100896 mistakenly removed it). Since then
there have been zero master failures in 17+ days; all remaining failures
are on the 26.3 branch and backport PRs targeting 26.3.
@Algunenano Algunenano self-assigned this May 15, 2026
@Algunenano Algunenano assigned Algunenano and unassigned Algunenano May 15, 2026
robot-ch-test-poll1 added a commit that referenced this pull request May 18, 2026
Cherry pick #101580 to 26.3: Fix flaky test 03706_statistics_preserve_checksums_on_mutations
robot-clickhouse added a commit that referenced this pull request May 18, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 18, 2026
Algunenano added a commit that referenced this pull request May 19, 2026
Backport #101580 to 26.3: Fix flaky test 03706_statistics_preserve_checksums_on_mutations
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 10, 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 pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants