Skip to content

Pin automatic_parallel_replicas_ignore_thresholds in 05617_autopr_undecided_retry - #133449

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05617-autopr-ignore-thresholds
Nov 22, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05617-autopr-ignore-thresholds

Conversation

@groeneai

@groeneai groeneai commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #130565

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):

Not required.

Description

05617_autopr_undecided_retry (added in #130565) fails in Stateless tests (amd_debug, ParallelReplicas, s3 storage, parallel) on two unrelated PRs (report 1, report 2), both times with only undecided_warm_3 reading 1 0 0 1 0 1 instead of 0 0 0 0 0 1.

That job installs the automatic parallel replicas profile on every odd-SHA commit (parallel_replicas_job_runs_autopr), and the profile sets automatic_parallel_replicas_ignore_thresholds = 1. With the cap on how many threads a read can occupy, the small warm read is clamped to one thread on both sides, so the third run declines without building the plan, as the reference expects. With the cap ignored, the comparison favours parallel replicas, and the third run declines only while the duplicated-read share measured by the second run exceeds automatic_parallel_replicas_max_duplicated_read_ratio. In the higher mode of the measured input (120-137 KB instead of about 45 KB) it does not: the third run builds the plan, applying it is refused because the single-node plan reads t_undecided_wt twice, and the run counts AutoParallelReplicasPlansNotComparable.

The warm case now pins automatic_parallel_replicas_ignore_thresholds = 0, as 04035_autopr_no_parallel_replicas_for_small_reads does; a query-level SET overrides the profile. Reverting #130565 (also in 26.10 and 26.11) would stop the failures too, but its code is not at fault.

Locally (debug build, CI --autopr profile, settings of the two failing runs): 20/20 and 19/20 failures before, 0/50 and 0/50 after; 50 randomized runs each under the automatic and the plain parallel replicas profiles pass.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.151-master (included in 26.12 and later)

…undecided_retry`

The `ParallelReplicas` stateless job installs the automatic parallel
replicas profile on every second commit (`parallel_replicas_job_runs_autopr`,
odd SHA). That profile sets `automatic_parallel_replicas_ignore_thresholds = 1`,
which drops the cap on how many threads a read can occupy.

The third run of the warm case expects to decline from the remembered
boundary without building the probe plan. With the cap on, the read of a few
hundred KB occupies one thread, both sides of the cost model compare equal and
the query declines. With the cap ignored, the comparison becomes
`input / 4 > input / 12 + output / 3`, which favours parallel replicas whenever
the duplicated-read ratio measured by the second run stays below 0.5. The
measured input is bimodal across runs of the same statement (about 45 KB or
120-137 KB); in the high mode the third run builds the plan, applying it is
refused because the single-node plan reads `t_undecided_wt` twice, and the run
counts `AutoParallelReplicasPlansNotComparable`, so `undecided_warm_3` reads
`1 0 0 1 0 1` instead of `0 0 0 0 0 1`.

Pin the cap in the warm case, as `04035_autopr_no_parallel_replicas_for_small_reads`
does. A query-level `SET` overrides the server profile.

Locally, under the `--autopr` profile with the settings drawn by the two failing
CI runs: 20/20 and 19/20 failures before, 0/50 and 0/50 after; 50 randomized runs
each under the automatic and the plain parallel replicas profiles pass.

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. My own review of the diff: 0 findings (one wording fix in the description, applied before opening).

Session id: cron:clickhouse-review-slot-10:20261121-224501

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Local debug build of master a2126db, server with the CI --autopr profile, tests/clickhouse-test 05617_autopr_undecided_retry --autopr --no-parallel-replicas with the settings of the failing CI run: 20/20 FAIL with the CI diff (19/20 with the other failing run's settings).
b Root cause explained? Yes. On odd-SHA commits the ParallelReplicas job uses the automatic parallel replicas profile, which sets automatic_parallel_replicas_ignore_thresholds = 1. Without the read-thread cap the cost model favours parallel replicas for the warm read; when the input measured by the second run is in its higher mode (119-137 KB) the third run builds the plan, the apply is refused because the single-node plan reads t_undecided_wt twice, and AutoParallelReplicasPlansNotComparable is counted. With the cap the read gets one thread on both sides and the run declines without building, as the reference expects.
c Fix matches root cause? Yes. Pins exactly the setting the profile flips, at query level, only in the case that reaches the cost model, as 04035_autopr_no_parallel_replicas_for_small_reads does. No tag, no blacklist entry, reference unchanged.
d Test intent preserved / new tests added? Yes. The reference still asserts that the third warm run decides without building the plan; with the pin that holds for any measured input below 1 MiB. Test-only change.
e Both directions demonstrated? Yes, same binary, both CI settings draws: 20/20 and 19/20 FAIL before, 0/50 and 0/50 after. Control on the unmodified test with --client-option automatic_parallel_replicas_ignore_thresholds=0: 20/20 OK. query_log: all 120 runs with the cap took DecidedWithoutBuildingPlan + RejectedByCostModel.
f Fix is general across code paths? Yes. The other cases of the test never reach the cost model and matched the reference under the automatic profile. Of the other automatic parallel replicas tests asserting a cost-model outcome, 04035 and 05257 already pin the cap and 05480 sets it to 1 on purpose; none of the rest fails this way.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test setting pin, no product code). 50 randomized runs each under the automatic and the plain parallel replicas profiles pass.
h Backward compatible? (maintainer-approved exception only) Yes. Test-only, no setting default or format change.
i Invariants and contracts preserved? Yes. The pin joins the SET that already pins the other settings of that case; one reference line per case, the undecided_ comments and the initial-query filter are unchanged.

Session id: cron:clickhouse-impl-slot-41:20261121-222800

@clickhouse-gh

clickhouse-gh Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [16b004f]

Summary: ✅


AI Review

Summary

Pins automatic_parallel_replicas_ignore_thresholds = 0 for the warm-statistics case in 05617_autopr_undecided_retry, stabilizing its expected decision under the automatic parallel replicas CI profile. No actionable findings; the existing assertions and reported repeated before/after validation support this test-only fix.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). labels Nov 21, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 22, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 22, 2026
Merged via the queue into ClickHouse:master with commit afad0a9 Nov 22, 2026
387 of 389 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label 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-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