Skip to content

Clamp random granularity in test 05020_top_k_through_array_join_explain - #128015

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05020-clamp-random-granularity
Nov 4, 2026
Merged

Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05020-clamp-random-granularity

Conversation

@groeneai

@groeneai groeneai commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #116550

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 05020_top_k_through_array_join_explain now keeps the randomized index_granularity and index_granularity_bytes at 100 rows / 100000 bytes or above, so its single 100-row part always has one granule.

Description

The test was added by #116550. Failing job: Stateless tests (arm_binary, parallel): every ReadFromMergeTree step prints Parts: 1 | Granules: 3 instead of Granules: 1. The runner's own diagnosis isolated index_granularity = 37 (359/359 fail with the drawn settings, 0/383 without).

The test inserts 100 rows and asserts the full EXPLAIN text. The runner raises the granularity floors to 100 rows / 100 KiB only on debug, sanitizer and coverage builds, so on release-flavour jobs a draw below 67 rows (below 100 on a wide part, since compact parts fold a short tail into the previous granule) or below ~2.7 KB of index_granularity_bytes splits the part.

The fix adds -- Random settings limits: index_granularity=(100, None); index_granularity_bytes=(100000, None), the same line 20 other tests carry. Both settings stay randomized above the floors; the queries and the reference are unchanged.

Validation (debug build, runner copy forcing the draw after the floor):

  • forced index_granularity 1..66: 20/20 fail before, 20/20 pass after (logged value 100 every run); 67..99: fails exactly on the wide-part draws;
  • forced index_granularity_bytes 1024..2048: 20/20 fail before, 20/20 pass after (logged 100000);
  • with the line misspelled the low values come back and it fails 5/5;
  • 50/50 randomized runs pass.

🤖 Generated with Claude Code


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

Version info

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

The test inserts 100 rows into a MergeTree table and asserts the full
`EXPLAIN PLAN` text, including `Parts: 1 | Granules: 1` of every
`ReadFromMergeTree` step. The runner randomizes `index_granularity`
(1..65536) and `index_granularity_bytes` (1 KiB..30 MiB), and only raises
their floors to 100 rows / 100 KiB on debug, sanitizer and coverage
builds. On a release-flavour job a draw below 67 rows (any part type),
below 100 rows on a wide part, or below ~2.7 KB of bytes splits the part
into several granules, so the reference diffs on every read step
(`Granules: 3` with `index_granularity = 37` on arm_binary).

Add the same `Random settings limits` line 20 other tests carry: both
settings stay randomized above 100 rows / 100000 bytes, which keeps the
single 100-row part in one granule. The reference is 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; 1 full pass), plus my own cold review (0 blocker, 0 major).

Cross-checked against the code: one mark at the floor for both part types (fillIndexGranularityForWidePart / fillIndexGranularityForCompactPart with 100 rows and index_granularity = 100), and the byte split threshold (computeIndexGranularity: the ~5.4 KB block splits only for index_granularity_bytes at or below half of it). The 20 tests that carry the same Random settings limits line are parsed by the same runner path.

Session id: cron:clickhouse-review-slot-9:20261027-234900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. index_granularity = 37 on the test's table gives Granules: 3 every time; a runner copy forcing index_granularity 1..66 fails 20/20, index_granularity_bytes 1024..2048 fails 20/20.
b Root cause explained? The runner floors granularity at 100 rows / 100 KiB only on slow builds; on release-flavour jobs a lower draw splits the single 100-row part into several granules, and the reference hard-codes Granules: 1 on 12 read steps.
c Fix matches root cause? Yes. A per-setting Random settings limits floor states exactly the one-granule assumption; both settings stay randomized above it, no blanket tag.
d Test intent preserved / new tests added? Yes. Queries and .reference unchanged; the other MergeTree settings stay fully randomized. Test-only fix.
e Both directions demonstrated? Yes. Forced rows 1..66: 20/20 fail before, 20/20 pass after; forced bytes: 20/20 fail before, 20/20 pass after; misspelled line: 5/5 fail; 50/50 randomized runs pass.
f Fix is general across code paths? The 12 lines read the one table; sibling tests of the same PR (05019, 05021, 05441) do not assert granule counts and have 0 failures in 30 days.
g Fix generalizes across inputs (params/datatypes/wrappers)? Both row and byte granularity are clamped; wide and compact parts measured, boundary 100 gives 1 granule on both.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? The test's invariant "one part, one granule" now holds for every randomized run.

Session id: cron:clickhouse-impl-slot-7:20261027-233200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @yariks5s, could you review this and add the can be tested label so CI runs? The test from #116550 asserts Granules: 1 for a 100-row table, so on release-flavour jobs a random index_granularity below 100 (or a small index_granularity_bytes) splits the part and fails it; this adds a per-setting Random settings limits floor, and the queries and reference are unchanged.

@clickhouse-gh

clickhouse-gh Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9a6cef3]

Summary: ✅


AI Review

Summary

The PR stabilizes 05020_top_k_through_array_join_explain by setting lower bounds for randomized index_granularity and index_granularity_bytes, preserving its Granules: 1 expectation without changing the queries or reference output. No actionable findings. The release-build flaky check passed all 50 iterations.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 28, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6e31cc4

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
Fast test (arm_darwin) / 05227_mutate_part_ahead_of_table_metadata_version_mergetree flaky, not from this PR (the test is not in its diff): the rewrite dropped the column: 1 instead of 0, failing on 113 PRs in 14 days; the tested merge tree predates the fix #127925 (mine, merged)
Mergeable Check, PR praktika rollups of the row above #127925 (the owner of the row above)

All five stateless flaky check builds passed on this head, and CH Inc sync is green. The earlier Config Workflow failures were the attempts before the can be tested label.

Session id: cron:our-pr-ci-monitor:20261028-170007

@Algunenano
Algunenano enabled auto-merge November 3, 2026 22:34
@Algunenano
Algunenano added this pull request to the merge queue Nov 4, 2026
Merged via the queue into ClickHouse:master with commit bf8a006 Nov 4, 2026
185 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 Nov 4, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 24, 2026
yariks5s added a commit that referenced this pull request Nov 24, 2026
Includes the backports of #116550, #128015 and #128926, which this change needs and which are not in 26.10 yet.
yariks5s added a commit that referenced this pull request Nov 24, 2026
Includes the backports of #116550 and #128015, which this change needs and which are not in 26.10 yet.
robot-ch-test-poll2 added a commit that referenced this pull request Nov 24, 2026
Cherry pick #128015 to 26.10: Clamp random granularity in test `05020_top_k_through_array_join_explain`
robot-clickhouse added a commit that referenced this pull request Nov 24, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 24, 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-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants