Skip to content

Fix flaky 04256_packed_skip_indices_layout_transitions under randomized sparse serialization - #109095

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04256-sparse-serialization-file-count
Jul 2, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04256-sparse-serialization-file-count

Conversation

@groeneai

@groeneai groeneai commented Jul 1, 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 into CHANGELOG.md):

...

Description

04256_packed_skip_indices_layout_transitions walks a single skip index through packed -> spilled -> repacked transitions and detects the spill by comparing system.parts.files (the total part file count) of the phase-3 (spilled) merged part against the phase-2 (packed) merged part, asserting phase 3 has strictly more files. It assumes the two parts differ only in the skip-index layout.

That assumption breaks under CI's randomized ratio_of_defaults_for_sparse_serialization. A low ratio makes ClickHouse decide sparse serialization per column per part based on that part's data. The phase-2 part (3072 rows) and the phase-3 part (13312 rows, different values) then disagree on whether the id/w columns are sparse-serialized, adding/removing per-column substream files (id.sparse.idx.bin, id.sparse.idx.cmrk2, ...). That column-file delta is unrelated to the index and can cancel or outweigh the +1 file from the index spill, so phase3_spilled_has_more_files_than_packed flips to 0 and the test fails.

CI's own random-settings diagnosis isolated the single culprit ratio_of_defaults_for_sparse_serialization = 0.0013...: 22/22 fail with it, 35/35 pass without it. Reproduced locally with that exact value: phase2 part = 12 files vs 10 without it, while phase3 stays at 11, flipping the assertion.

Fix: pin ratio_of_defaults_for_sparse_serialization = 1.0 in the table's CREATE ... SETTINGS so column serialization is dense and identical across phases; the file-count delta then reflects only the index layout, which is what the test measures. A table-level SETTINGS value overrides the runner's --allow_merge_tree_settings injection (ClientBase::addMergeTreeSettings only adds settings not already present), so the pin is immune to randomization. The .reference output is unchanged.

Validated with the official clickhouse-test harness: forcing the culprit setting, the unfixed test fails with exactly -phase3_spilled_has_more_files_than_packed 1 / +...0; with the fix it passes 20/20; and 50/50 runs pass with full randomization enabled.

Report of a failing run: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104927&sha=1ee52dfe467a323c97bbf48f3e2be1da35db58f0&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%2C%201%2F2%29

Version info

  • Merged into: 26.7.1.425 (included in 26.7 and later)
  • Backported to: 26.6.2.24

…ed sparse serialization

The test walks a single skip index through packed -> spilled -> repacked
transitions and detects the spill by comparing system.parts.files (the total
part file count) of the phase-3 (spilled) merged part against the phase-2
(packed) merged part, asserting phase 3 has strictly more files. It assumes
the two parts differ only in the skip-index layout.

That assumption breaks under CI's randomized ratio_of_defaults_for_sparse_serialization.
A low ratio makes ClickHouse decide sparse serialization per column per part
based on that part's data. The phase-2 part (3072 rows) and the phase-3 part
(13312 rows, different values) then disagree on whether the id/w columns are
sparse-serialized, adding or removing per-column substream files
(id.sparse.idx.bin, id.sparse.idx.cmrk2, ...). That column-file delta is
unrelated to the index and can cancel or outweigh the +1 file from the index
spill, so phase3_spilled_has_more_files_than_packed flips to 0 and the test fails.

CI's own random-settings diagnosis isolated the single culprit
(ratio_of_defaults_for_sparse_serialization = 0.0013...): 22/22 fail with it,
35/35 pass without it.

Pin ratio_of_defaults_for_sparse_serialization = 1.0 in the table's CREATE
SETTINGS so column serialization is dense and identical across phases; the
file-count delta then reflects only the index layout, which is what the test
measures. A table-level SETTINGS value overrides the runner's
--allow_merge_tree_settings injection, so the pin is immune to randomization.

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

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With ratio_of_defaults_for_sparse_serialization = 0.0013473485833727095 (the value CI's minimizer isolated), the test fails on demand: phase-2 part = 12 files vs 10 without it, phase-3 stays 11, so phase3_spilled_has_more_files_than_packed flips 1 -> 0. Reproduced both via clickhouse-local and the official clickhouse-test --merge-tree-settings "--ratio_of_defaults_for_sparse_serialization 0.0013...".
b Root cause explained? The test compares system.parts.files between the phase-2 (packed, 3072 rows) and phase-3 (spilled, 13312 rows) merged parts and attributes the delta to the skip-index layout alone. A low ratio_of_defaults_for_sparse_serialization makes sparse serialization a per-part, data-dependent decision; the two different-data parts disagree on column sparse-serialization, adding/removing per-column substream files (id.sparse.idx.bin, id.sparse.idx.cmrk2) that swamp the +1 file from the index spill.
c Fix matches root cause? Yes. Pinning ratio_of_defaults_for_sparse_serialization = 1.0 makes column serialization dense and identical across phases, so the file-count delta reflects only the index layout, exactly the culprit setting CI isolated.
d Test intent preserved? Yes. The assertion is unchanged; the .reference is unchanged. The test still verifies the packed -> spilled -> repacked index-layout transition via the same file-count comparison, now free of the column-serialization noise. Only one MergeTree randomization is pinned (the one that breaks the file-count invariant), not a blanket no-random-merge-tree-settings tag.
e Demonstrated in both directions? Yes. Official harness: unfixed + forced culprit -> [ FAIL ] with diff -phase3_spilled_has_more_files_than_packed 1 / +...0; fixed + forced culprit -> 20/20 pass; fixed + full randomization -> 50/50 pass.
f Fix is general, not a narrow patch? N/A (flaky test setting fix, not a code bug). The pin is on the one table the test uses; there is no sibling code path.
g Fix generalizes across inputs? N/A (flaky test setting fix, not a code bug).
h Backward compatible? N/A (flaky test setting fix, not a code bug).
i Invariants and contracts preserved? N/A (flaky test setting fix, not a code bug). A table-level SETTINGS value takes priority over the runner's --allow_merge_tree_settings injection (ClientBase::addMergeTreeSettings only adds settings not already present), so the pin holds under randomization.

Session id: cron:clickhouse-worker-slot-1:20260701-214500

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Algunenano — could you review? You authored this test and the packed-skip-index packing logic (52c7427). It is flaky under randomized ratio_of_defaults_for_sparse_serialization: the phase-2 and phase-3 parts hold different data, so a low ratio makes them disagree on per-column sparse serialization, and that column-file delta swamps the +1 file from the index spill (CI's minimizer isolated exactly this setting). Fix pins ratio_of_defaults_for_sparse_serialization = 1.0 in the table SETTINGS so only the index layout moves the file count; assertion and reference unchanged.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [abe08ce]

Summary: ✅


AI Review

Summary

This PR pins ratio_of_defaults_for_sparse_serialization = 1.0 in 04256_packed_skip_indices_layout_transitions so randomized MergeTree settings cannot flip system.parts.files via sparse-serialization sampling instead of the packed-versus-spilled skip-index layout the test is meant to measure. The change is narrowly scoped, matches the current writer/sampling behavior, and I did not find a remaining contract violation in the updated test.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.73% 85.75% +0.02%
Functions 91.46% 91.46% +0.00%
Branches 78.28% 78.33% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 125 line(s), 6 function(s) across 46 file(s) · Details

Top files
  • src/Storages/WindowView/StorageWindowView.cpp: 22 line(s), 1 function(s)
  • src/AggregateFunctions/AggregateFunctionSparkbar.cpp: 5 line(s)
  • src/Functions/FunctionsNumericIndexedVector.h: 5 line(s)
  • src/Functions/UserDefined/UserDefinedExecutableFunctionFactory.cpp: 5 line(s)
  • src/Functions/dateName.cpp: 5 line(s)

Full report

@groeneai

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - abe08ce

Every failure below has an owner (a fixing PR). None is PR-caused: this PR is a test-only change (pins ratio_of_defaults_for_sparse_serialization in one stateless test) and cannot cause a suite-wide job-wrapper error.

Check / test Reason Owner / fixing PR
Stateless tests (amd_tsan, s3 storage, parallel, 2/2) transient job-level ERROR (exit 125, results: [], no individual test failed) - praktika watchdog timeout-cleanup hang #109096 (ours, open)
Mergeable Check / PR aggregators reflecting the single red leaf above n/a

Session id: cron:our-pr-ci-monitor:20260702-050000

@Algunenano Algunenano self-assigned this Jul 2, 2026
@Algunenano
Algunenano added this pull request to the merge queue Jul 2, 2026
Merged via the queue into ClickHouse:master with commit 317f388 Jul 2, 2026
347 of 348 checks passed
@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 Jul 2, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 2, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 2, 2026
clickhouse-gh Bot added a commit that referenced this pull request Jul 2, 2026
Backport #109095 to 26.6: Fix flaky 04256_packed_skip_indices_layout_transitions under randomized sparse serialization
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-sparse-serialization-file-count

Fix flaky 04256_packed_skip_indices_layout_transitions under randomized sparse serialization
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.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants