Skip to content

Bound the randomized index granularity in test 04604_adaptive_aggregator_compaction - #125345

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04604-adaptive-aggregator-compaction-granularity
Oct 12, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04604-adaptive-aggregator-compaction-granularity

Conversation

@groeneai

@groeneai groeneai commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #119337

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

Bound the randomized index_granularity and index_granularity_bytes in the test 04604_adaptive_aggregator_compaction.

Description

04604_adaptive_aggregator_compaction timed out (600 s) in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) on #119337. The runner's rerun reproduced it with the same draw and passed 107/107 without randomization.

The MergeTree randomizer drew index_granularity = 7 with min_bytes_for_wide_part = 1073741824, so the 200,000-row test_skew became one compact part on cached_s3_encrypted with 28,572 granules. With enable_filesystem_cache = 0, each multi-column scan issued about one S3 GET per granule (~2.3 ms each): the first six cells took 595.6 s for 263,039 GETs, while the one-column sum(k) cell needed 4 GETs. CPU was 16-33 s per cell, so the time is in the reads, not in the adaptive aggregator.

The test compares each aggregation with the adaptive aggregator off and on, with max_block_size = 8192 pinned, so granularity is not part of what it checks. This adds -- Random settings limits: index_granularity=(100, None); index_granularity_bytes=(100000, None), the lower bounds (100 rows, ~100 KB) the runner already applies to long tests and slow builds (e185707), as #123765 did for 03100_lwu_41_bytes_limits. Granularity stays randomized above the bounds. The line sits below the header comment, so it merges cleanly with #123531.

Validation (debug build, local MinIO, the lane's encrypted S3 policy and parallel-replicas cluster):

  • CI draw replayed with fixed settings: 498.7 s, 414,712 GETs, 0.5 to 2.0 GETs per mark in every multi-column cell.
  • Same draw with index_granularity = 100: 32.4 s, 28,076 GETs.
  • With a runner patched to draw granularity 1..50, all 20 CREATEs in 10 runs got 100 / 100000; with the line corrupted, the raw draws came through.
  • 50/50 randomized runs on S3 with parallel replicas, 50/50 on local disk.

With a wide part at granularity 7, the String cell needs 8 GETs instead of 57,146, so the per-granule GETs are specific to compact parts.


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

Version info

  • Merged into: 26.10.1.2224-master (included in 26.10 and later)

…ction

With `index_granularity = 7` and `min_bytes_for_wide_part = 1073741824`
the test's 200,000-row table is one compact part with 28,572 granules.
On S3 with the filesystem cache off, each multi-column scan of it issues
about one GET per granule, and the test scans the table about 20 times,
so it hit the 600 s limit in `Stateless tests (arm_binary,
ParallelReplicas, s3 storage, parallel)` (263,039 GETs, ~2.3 ms each,
in the first six cells).

The test compares aggregation results with the adaptive aggregator off
and on, with `max_block_size` pinned, so it does not depend on
granularity. Apply the lower bounds the runner already uses for `long`
tests and slow builds (e185707), keeping both settings randomized
above them. The line goes below the header comment so it does not
conflict with the open ClickHouse#123531, which rewrites that comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 12, 2026
@groeneai

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

Independent review of c71be111d094 (own cold review + Gate B, codex): 0 blockers, 0 majors.

Finding Verdict
💡 The runner's coarse floor for index_granularity_bytes is 100 * 1024, the clamp uses 100000 (the in-tree spelling of 01780/03100). AGREE, wording only: the description says "~100 KB".
💡 Six-cell wall time in the description was the five-cell sum. AGREE, corrected to 595.6 s.

Checked: the runner scans every line for the limits prefix (find_random_settings_limits_line), so the line below the header parses; the clamp reaches both CREATEs; the result range equals the runner's own range for long tests and slow builds, where this test ran 0 failures in 30 days on the S3 lanes (max 66.1 s on TSan).

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The CI draw replayed with fixed settings (encrypted S3, the lane's parallel-replicas cluster) gives the CI signature: one compact part with 28,572 granules, about one S3 GET per granule in every multi-column cell (414,712 GETs).
b Root cause explained? index_granularity = 7 with min_bytes_for_wide_part = 1073741824 makes the 200,000-row table one compact part on S3; with the filesystem cache off each multi-column scan issues one range GET per granule, and the test scans the table about 20 times.
c Fix matches root cause? Yes. It clamps exactly the two settings that produce the granule count (index_granularity >= 100, index_granularity_bytes >= 100000), the bounds the runner already applies to long tests and slow builds. No blanket no-random-* tag, no smaller dataset.
d Test intent preserved / new tests added? Yes. Assertions and .reference are unchanged, max_block_size = 8192 is pinned so the aggregator sees the same blocks, and both granularity settings stay randomized above the bounds. Test-only fix, no new test needed.
e Both directions demonstrated? Yes, same draw: granularity 7 gives 414,712 GETs (498.7 s), 100 gives 28,076 GETs (32.4 s). All 20 CREATEs with a runner patched to draw 1..50 got 100 / 100000; a corrupted line let the raw draws through. 50/50 on S3 + parallel replicas, 50/50 local.
f Fix is general across code paths? N/A (test-only). 04603_adaptive_aggregator already carries a granularity bound; the other family tests are long (bounded by the runner) or read numbers().
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). The clamp reaches both CREATEs (test_skew, test_skew_sparse).
h Backward compatible? (maintainer-approved exception only) N/A: one comment line in a test.
i Invariants and contracts preserved? Under CI randomization this test never creates a part with more than about 2,000 granules. Verified for both CREATEs.

Session id: cron:clickhouse-impl-slot-6:20261012-075200

@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c71be11]

Summary: ✅


AI Review

Summary

This PR narrows the randomized MergeTree granularity settings for 04604_adaptive_aggregator_compaction so the test still exercises adaptive-aggregator compaction without wandering into the known compact-part/S3 timeout regime. I do not see a correctness or coverage regression in the change: the new limits match existing in-tree practice for similar stateless tests, and clickhouse-test scans the full file for the Random settings limits: comment, so placing the line under the test prologue still applies it to the whole case.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 12, 2026
@groeneai
groeneai requested a review from nihalzp October 12, 2026 08:34
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 12, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 12, 2026
Merged via the queue into ClickHouse:master with commit 4d855f6 Oct 12, 2026
177 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 12, 2026
@clickhouse-gh clickhouse-gh Bot added comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). 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-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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