Skip to content

Fix flaky test 05407_map_buckets_zero_key_read_volume - #127222

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05407-map-buckets-zero-key-read-volume
Oct 21, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05407-map-buckets-zero-key-read-volume

Conversation

@groeneai

@groeneai groeneai commented Oct 21, 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

Related: #125713

Failing job: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127094&sha=63db7409ea64cf1eb9ee2c34e4270f52e174824a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20AsyncInsert%2C%20s3%20storage%2C%20parallel%29

The test checks that m[0.0] (all four buckets) reads more than twice the compressed bytes of m[3.0] (one bucket). In that job it printed 0, and the runner's rerun with the same settings failed 14 of 120 times. Both sums were always correct.

The randomized merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability is decided per query. When it fires on a read with two or more streams, the read is split into layers, the sorting key id is read too, and the border granule is read twice. If it fires on the one-bucket query only, that query reads 84521 bytes instead of 39760, against 159659, and the ratio drops to 1.89. That was the case for all 15 failures among the job's 121 runs, and for no passing run. Two streams need object storage, max_threads > 1 and a small index_granularity, and the drop is only that large with the ZSTD(3) default codec that CI picks for a third of the jobs (about 2.2 with LZ4 or ZSTD(1)).

The change clamps the injection to 0 for this test; all other settings stay randomized.

Validation with two streams forced on local disk (max_threads 3, concurrent-read thresholds 1, index_granularity 1140, default_compression_codec ZSTD(3)), which gives the job's exact byte counts: old test 24/120 runs fail, new 0/120, new with a misspelled clamp 17/120; default randomization 150/150.


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

Version info

  • Merged into: 26.11.1.482-master (included in 26.11 and later)

Clamp `merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability`
to 0 for this test.

The test checks that `m[0.0]` (all four buckets of a bucketed `Map`) reads more than twice the
compressed bytes of `m[3.0]` (one bucket). The injection is decided per query; when it fires on a
read with two or more streams, the read is split into layers, the sorting key `id` is read too and
the border granule is read twice. When it fires on the one-bucket query only, that query reads
84521 instead of 39760 compressed bytes against 159659, so the ratio is 1.89 and the check prints 0.
That is the cell of all 15 failures among the 121 runs of the failing CI job (PR ClickHouse#127094,
`Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel)`).

It needs two read streams (object storage, `max_threads > 1`, a small `index_granularity`) and the
`ZSTD(3)` server default codec that `tests/config/install.sh` picks for a third of the jobs: with
`LZ4` or `ZSTD(1)` the same case gives a ratio of about 2.2 and passes.

Validated with two streams forced on local disk (`max_threads=3`, concurrent-read thresholds 1,
`index_granularity=1140`, `default_compression_codec='ZSTD(3)'`), which reproduces the job's byte
counts exactly: old test 24/120 fail, new 0/120, new with a misspelled clamp line 17/120; default
randomization 150/150.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (0 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ The Stress job passes the injection as --client-option ...=0.05 (ci/jobs/scripts/stress/stress.py:474-476), which overrides the clamp, so the test stays flaky there DISAGREE The Stress job never reports a per-test reference mismatch: ci/jobs/stress_job.py builds its result only from test_results.tsv, which holds server-level rows (server died, hung check, start/shutdown, log errors, script exit code), and the clickhouse-test worker exit codes (stress.py:838-846) are not evaluated. No other CI path sets this setting.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261021-151500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Two streams forced on local disk (max_threads=3, merge_tree_min_rows/bytes_for_concurrent_read=1, index_granularity=1140, default_compression_codec='ZSTD(3)'): the old test fails 24/120 runs, always with the CI diff (-1 / +0 on the last line).
b Root cause explained? The randomized PartsSplitter injection fires per query; on the one-bucket query only, it also reads the sorting key and a border granule twice, so that query reads 84521 instead of 39760 compressed bytes against 159659, ratio 1.89 < 2. Matches all 15 failures of the CI job's 121 runs.
c Fix matches root cause? Yes. The test clamps exactly that injection to 0 with a Random settings limits line; no bound widened, no blanket tag, everything else stays randomized.
d Test intent preserved / new tests added? Yes. Data and oracle unchanged; with the fix the ratio is 3.76..4.08, so a one-bucket lookup that read all buckets would still fail it.
e Both directions demonstrated? Yes. Old 24/120 fail, new 0/120 (injection never non-zero in query_log), new with a misspelled clamp 17/120; default randomization 150/150.
f Fix is general across code paths? N/A (flaky test setting fix, not a code bug). Other tests asserting ReadCompressedBytes either pin the injection already or show no failures linked to it.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (flaky test setting fix, not a code bug).
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? Yes. Uses the runner's documented per-setting clamp; no product code touched.

Session id: cron:clickhouse-impl-slot-4:20261021-150000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @harikrishnan94, could you review this and add the can be tested label so CI runs? The randomized merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability sometimes fires only on the one-bucket query of 05407_map_buckets_zero_key_read_volume, which then also reads the sorting key and drops the byte ratio below 2, so the test now clamps that injection to 0.

@clickhouse-gh

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [16ecc58]

Summary: ✅


AI Review

Summary

PR #127222 pins randomized PartsSplitter fault injection to zero for 05407_map_buckets_zero_key_read_volume, preventing independent query-level injection from distorting its compressed-byte comparison. The change preserves the result checks and byte-ratio assertion. No actionable findings at commit 16ecc583285c47ac83371dc62b692a957f6bd8de; the documented before/after reruns provide focused validation for this test-only fix.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 21, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 21, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 21, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 21, 2026
Merged via the queue into ClickHouse:master with commit ef2f9c8 Oct 21, 2026
352 of 353 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 Oct 22, 2026
@clickhouse-gh clickhouse-gh Bot added comp-map-datatype Map datatype implementation and semantics. and removed comp-testing Test content only (no production code). 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-map-datatype Map datatype implementation and semantics. pr-ci 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.

3 participants