Skip to content

Pin the compression codec in 05257_autopr_rejected_by_cost_model - #132570

Merged
nickitat merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/pin-codec-05257-autopr-rejected-by-cost-model
Nov 18, 2026
Merged

nickitat merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/pin-codec-05257-autopr-rejected-by-cost-model

Conversation

@groeneai

@groeneai groeneai commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120438

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

05257_autopr_rejected_by_cost_model fails on master in every autopr-mode ParallelReplicas run whose job drew LZ4 as the server default codec, e.g. Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel, 1/2) at e8cb3beb96c3 (3 of 3 reruns): the second query applies parallel replicas instead of being declined.

Since #120438 these runs set automatic_parallel_replicas_ignore_thresholds = 1, so the verdict rests on the cost formula alone: at max_threads = 4 and 3 replicas it applies when the shipped bytes are less than half the read bytes. The shipped keys are always priced with ZSTD(3), the factory default codec, while the read is priced with the part's codec, which tests/config/install.sh randomizes across LZ4, ZSTD(1) and ZSTD(3). On a ZSTD(3) part both sides price alike (188256 / 4 ? (188256 / 12 + 188256 / 3), 47064 < 78440, declined); on an LZ4 part the read costs about twice the shipped bytes (400341 / 4 ? (400341 / 12 + 188256 / 3), 100085 > 96113, applied), which is the line in the failing job's server log.

The test now pins default_compression_codec = 'ZSTD(3)' on its table, the mechanism install.sh documents for codec-sensitive tests and the one 03634_autopr_input_bytes_estimation_compact and 04100_autopr_input_bytes_estimation_aggregation_in_order use. Reverting #120438 would also stop the red, but it drops the autopr coverage that PR added, which only exposed this codec dependence.

Validation (debug build, server default codec LZ4, automatic_parallel_replicas_ignore_thresholds = 1): the unchanged test fails 6/6 with the CI diff and the CI formula line; with the pin it passes 3/3, 50/50 with random settings and 50/50 without the setting, and 6/6 each under ZSTD(1) and ZSTD(3). With the autopr profile and LZ4, the 87 autopr tests that do not need the stateful dataset pass, with and without random settings.

🤖 Generated with Claude Code


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

Version info

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

Since ClickHouse#120438 the autopr ParallelReplicas runs set
`automatic_parallel_replicas_ignore_thresholds = 1`, so the read cap no
longer declines this small read and the verdict rests on the cost formula:
at `max_threads = 4` and 3 replicas it applies when the shipped bytes are
less than half the read bytes.

The shipped keys are priced with the factory default codec ZSTD(3), the
read with the part's codec, which tests/config/install.sh randomizes across
LZ4, ZSTD(1) and ZSTD(3). On a ZSTD(3) part both sides are 188256 bytes
(47064 < 78440, declined); on an LZ4 part the read is 400341 bytes
(100085 > 96113, applied), which is what the failing coverage job logged.

Pin `default_compression_codec = 'ZSTD(3)'` on the table, as install.sh
documents for codec-sensitive tests and as 03634 and 04100 already do.

Validation (debug build, server default codec LZ4, ignore_thresholds = 1):
unchanged test 6/6 FAIL with the CI diff and formula line; pinned test 3/3
OK, 50/50 randomized with and without the setting, 6/6 each under ZSTD(1)
and ZSTD(3); all 87 runnable autopr tests pass under LZ4 with the autopr
profile.

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; 0 findings), plus a separate cold review (1 nit below).

# Sev Finding Verdict Evidence / action
1 💡 On a wide part the read is priced from the on-disk ratio, so a very small randomized insert-time max_compress_block_size / min_compress_block_size could still push the read bytes past twice the shipped bytes AGREE, noted, not blocking It needs compressed blocks of a few hundred bytes (about 0.01% of draws). In 50 randomized runs with the cap ignored every decision declined; the lowest shipped/read ratio was 0.63, and the model applies only below 0.50.

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

Session id: cron:clickhouse-review-slot-9:20261118-032301

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Server default codec LZ4 (what install.sh writes), --client-option automatic_parallel_replicas_ignore_thresholds=1: the unchanged test fails 6/6 with the CI diff (0 1 1 0 1 -> 0 1 0 1 0).
b Root cause explained? Yes. With the read cap ignored the verdict is O < I / 2 at 4 threads and 3 replicas. O is priced with ZSTD(3), I with the part's codec; on an LZ4 part I = 400341, O = 188256, so it applies (100085 > 96113, the CI log line).
c Fix matches root cause? Yes. The table pins the codec the output is priced with, so both sides price alike. No bound widened, no tag added, randomization stays on, .reference unchanged.
d Test intent preserved / new tests added? Yes. The test still asserts the decline is reported by AutoParallelReplicasRejectedByCostModel after a cost-model evaluation; the formula line is present in every run. The modified test is the deliverable.
e Both directions demonstrated? Yes. Same server, binary and command: 6/6 FAIL before, 3/3 OK after (188256 / 4 ? (188256 / 12 + 188256 / 3), 47064 < 78440).
f Fix is general across code paths? Yes. The sibling autopr tests that assert byte-driven verdicts already pin their codec; all 95 autopr tests under LZ4 with the autopr profile show no other reference diff.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Codec axis covered: LZ4 / ZSTD(1) / ZSTD(3) server defaults, compact and wide parts; 50/50 randomized with and without the setting.
h Backward compatible? (maintainer-approved exception only) N/A. Test-only, no setting or behaviour change.
i Invariants and contracts preserved? N/A for product code. The table setting overrides the server <merge_tree> default; the reference output is unchanged.

Session id: cron:clickhouse-impl-slot-40:20261118-025900

@clickhouse-gh

clickhouse-gh Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [33668b0]

Summary: ✅


AI Review

Summary

PR #132570 pins default_compression_codec to ZSTD(3) in 05257_autopr_rejected_by_cost_model, removing the randomized server codec as a cause of unexpected parallel-replica decisions. Reviewed head 33668b0956e05071ff9ec4323607a2ae29d32b6b, the complete diff, surrounding estimation logic, and all prior discussion. The existing profile-event assertions remain intact, and the supplied before/after and randomized validation supports this focused test correction. No actionable findings. No local tests were run.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 18, 2026
@nickitat nickitat self-assigned this Nov 18, 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-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). 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