Skip to content

Fix 05401_autopr_set_transplant_unpaired_sets timeout with small randomized index granules - #127515

Merged
devcrafter merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05401-small-granules-timeout
Oct 24, 2026
Merged

devcrafter merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05401-small-granules-timeout

Conversation

@groeneai

@groeneai groeneai commented Oct 22, 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):

The test 05401_autopr_set_transplant_unpaired_sets now keeps the randomized index_granularity and index_granularity_bytes at their defaults or above, so it no longer times out when the runner draws tiny granules.

Description

Related: #126141 (added the test)

Failing master job: Stateless tests (amd_tsan, s3 storage, parallel, 3/3), Reason: Timeout!. All 5 failures in 30 days (master, merge queue, PR flaky checks) drew index_granularity below 200 (8, 29, 102, 117, 162).

Every query reads the 1M-row table in one thread with 1 KiB remote read tasks, so its cost grows with the number of granules. In the master failure (index_granularity = 117, filesystem cache off) each sumIf ... IN query read 17094 marks with ~20300 S3 GETs and took 109-243 s. index_granularity_bytes = 1024 alone gives ~20k marks too.

The fix adds -- Random settings limits: index_granularity=(8192, None); index_granularity_bytes=(10485760, None), the same line as 05175_autopr_lazy_read_statistics: the engine defaults as lower bounds, both still randomized above them. The queries and the reference are unchanged.

Validation (debug build, local MinIO):

  • the master failure's own settings: 101 s (17094 marks and 20299 GETs per query, as in CI), 2.0 s with only the two granule settings at the floors; the settings of an index_granularity = 8 failure give Timeout! at 600 s, 2.3 s at the floors;
  • runner forced to draw the master values: the new file logs index_granularity = 8192, index_granularity_bytes = 10485760 and runs in 1-2.5 s; with the line misspelled it keeps 117 / 4101855 and runs 23-120 s;
  • 50/50 randomized runs on local disk and 50/50 on S3 pass with no draw below the floors (7 and 17 of 50 were below them with the line misspelled).

🤖 Generated with Claude Code


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

Version info

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

…ranules

The test reads its 1M-row table in one thread with 1 KiB read tasks in every
query, so its run time is proportional to the number of marks. The runner
randomizes index_granularity down to 1 (100 on slow builds) and
index_granularity_bytes down to 1024; every failing run in 30 days drew a
granularity below 200 (8, 29, 102, 117, 162). On the true master failure
(amd_tsan, s3 storage) the table had 8547 marks and four queries took
109-243 s each (17094 selected marks, ~20300 S3 GETs each). In one debug
flaky check, 50 runs took 17-31 s at every granularity >= 4037 and 134 s at 517.

Floor both settings at the engine defaults with a per-setting
`Random settings limits` line, as in 05175_autopr_lazy_read_statistics;
draws above the defaults stay randomized. Queries and reference unchanged.

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 my own review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The test comment's "tiny read tasks" clause is loose: merge_tree_min_bytes_per_task_for_remote_reading = 1024 only keeps remote read tasks from being enlarged; the cost driver on every storage is the mark count AGREE, noted, not blocking MergeTreeReadPoolBase.cpp:376-392; the clamp line itself is unaffected

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

Session id: cron:clickhouse-review-slot-8:20261022-233900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On a debug build against a local MinIO, the exact client settings of the index_granularity = 8 CI failure give Timeout! at 600 s every time; the master failure's settings give 101 s with CI's own counters (17094 marks, 20299 S3 GETs per query).
b Root cause explained? Every query reads the 1M-row table in one thread with 1 KiB remote read tasks, so the cost is per mark (~1.2 S3 GETs each with the filesystem cache off). Randomized index_granularity / index_granularity_bytes down to 1 / 1024 multiply the marks by up to ~1000x; all 5 failures in 30 days drew a granularity below 200.
c Fix matches root cause? Yes. A per-setting Random settings limits line floors exactly those two settings at their defaults; both stay randomized above them, and nothing else (queries, data size, task size, the other MergeTree settings) changes.
d Test intent preserved / new tests added? Yes. Queries and reference unchanged; the switched / plans_not_comparable checks passed at every granularity measured, and the floors are values most runs already draw.
e Both directions demonstrated? Yes. Runner forced to draw the master values (117 / 4101855): with the line the CREATE logs 8192 / 10485760 and runs in 1-2.5 s; with the line misspelled it keeps 117 / 4101855 and runs 23-120 s. 50 randomized runs: 0 draws below the floors with the line, 7 and 17 without it.
f Fix is general across code paths? N/A (test-only). The line covers both tables of the test; the sibling autopr tests with the same one-thread, 1 KiB-task shape already pin the granularity, and 05175 carries the same line.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Both granule settings are bounded; index_granularity_bytes = 1024 alone was measured at ~20k marks, so it needs the bound too.
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? Yes. The runner applies the limits to its randomized MergeTree settings before building the client command line; 50/50 randomized runs pass on local disk and 50/50 on S3.

Session id: cron:clickhouse-impl-slot-6:20261022-230400

@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [30f7da6]

Summary: ✅


AI Review

Summary

The PR floors randomized index_granularity and index_granularity_bytes at the MergeTree defaults for 05401_autopr_set_transplant_unpaired_sets, preventing excessive granule counts from timing out the test while preserving its queries and assertions. No actionable findings. The fix passed 50 debug and 50 TSan/S3 targeted CI runs at e79354c33144; stateless CI for the updated head 30f7da6c7cb7 is still pending.

Final Verdict

Status: ✅ Approve

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @devcrafter, could you review this and add the can be tested label so CI runs? It floors the randomized index_granularity / index_granularity_bytes of 05401_autopr_set_transplant_unpaired_sets at their defaults with a Random settings limits line: every timeout drew a granularity below 200, so each one-thread query read ~17k marks (~20k S3 GETs) and the test passed 600 s. It applies cleanly on top of #127396.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e79354c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / Some queries hung flaky, not from this PR: the hung query is the parallel replicas secondary read of 04117_detach_database_kill_query (is_initial_query: 0, sleepEachRow(3)); same hang on master (8 runs) and 40 other PRs in 7 days #127149 (mine, open)
Mergeable Check, PR praktika rollups of the row above #127149 (the owner of the row above)

Session id: cron:our-pr-ci-monitor:20261023-123007

@devcrafter
devcrafter added this pull request to the merge queue Oct 24, 2026
Merged via the queue into ClickHouse:master with commit 13f5158 Oct 24, 2026
178 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 24, 2026
@clickhouse-gh clickhouse-gh Bot added comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). 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-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