Skip to content

Fix flaky test 03100_lwu_30_join_cache - #125032

Merged
PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-03100-lwu-30-join-cache-granularity
Nov 4, 2026
Merged

PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-03100-lwu-30-join-cache-granularity

Conversation

@groeneai

@groeneai groeneai commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #124829

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 03100_lwu_30_join_cache.

Description

03100_lwu_30_join_cache timed out in Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential): the client waited 300 s for OPTIMIZE ... FINAL. The runner's rerun reproduced it with the same draw and passed 28/28 without randomization.

The MergeTree randomizer drew index_granularity = 20 with min_bytes_for_wide_part = 1 GiB, so the three patch parts written by UPDATE were Compact, with 150,000 granules on S3. The merge reads a compact patch part with two S3 GETs per granule: 300,038 GETs and a 558 s merge (54 GETs and 1 s without randomization).

The test checks that OPTIMIZE FINAL applies the patches, which does not depend on granularity. This adds -- Random settings limits: index_granularity=(8192, None); index_granularity_bytes=(10485760, None): granules are never finer than the defaults and stay randomized above them. A first version with floors 1000 / 100000 failed the amd_binary flaky check at 184.87 s. That check runs under ThreadFuzzer, where OPTIMIZE took 169 s at index_granularity = 1000, and 100000 bytes still cut the patch parts (44 bytes per row) into ~2,300-row granules.

Validation (local, CI amd_binary builds):

  • S3: the Share the dynamic top-K threshold across the sorting streams of ORDER BY ... LIMIT #124829 draw replayed gives return code 159 after 300 s and 300,038 GETs, as on CI; the GET count is linear in patch granules (6,038 at index_granularity = 1000).
  • ThreadFuzzer: the failing flaky-check draw took 657 s here (184 s on CI), 159 s with the new floors. The worst draw I found at the floors (vertical merge, Wide parts, sparse columns, patch_parts_version v2) took 431 s here, about 120 s at CI's speed.
  • With a runner patched to draw granularity 20..60, every CREATE got exactly 8192 / 10485760; with the line corrupted, the raw draws came through.

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

Version info

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

The test timed out in `Stateless tests (arm_binary, ParallelReplicas,
s3 storage, sequential)` on PR ClickHouse#124829: the client waited 300 s for
`OPTIMIZE ... FINAL`.

The MergeTree randomizer drew `index_granularity = 20` with
`min_bytes_for_wide_part = 1 GiB`, so the patch parts written by the
UPDATE were Compact parts with 150,000 granules on S3. Applying them in
the merge reads a compact patch part with two S3 GETs per granule:
300,038 GETs and a 558 s merge on CI, against 54 GETs and 1 s without
randomization. Release builds get no granularity floor from the runner
(it covers only slow builds and `long` tests), and this test is tagged
off every slow build.

Clamp both granularity settings with a per-test limits line. The row
floor is 1000 rather than the usual 100 because at 100 the same draw
still makes 60,000 GETs, about 110 s on CI. Granularity stays
randomized above the bounds; the test checks patch application, which
does not depend on it.

Validated on the amd_binary build of ClickHouse#124829 against local MinIO: the
CI draw replayed fails with return code 159 and 300,038 GETs; at the
floor it makes 6,038 GETs and passes in 7-8 s (patch_parts_version v1
and v2); a runner patched to draw granularity 20..60 gets exactly
1000 / 100000 in every CREATE, and the raw draws come through when the
line is corrupted; 50/50 randomized runs on S3 and on local disk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Oct 10, 2026
@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;
bounded: 1 full pass + 1 fix round + 1 delta recheck).

# Sev Finding Verdict Evidence / action
- - No findings on the one-line limits change - -

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-9:20261010-035000

@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 fails on demand with return code 159 after 300 s; the merge makes 300,038 S3 GETs, the same count as the CI job.
b Root cause explained? index_granularity = 20 with Compact patch parts on S3 gives 150,000 patch granules; the merge's patch reader makes two GETs per granule, so the merge takes ~558 s on CI.
c Fix matches root cause? Yes. It bounds the granule count for this test with a per-setting limits line; no timeout raise, no blanket tag, no smaller workload.
d Test intent preserved / new tests added? Yes. Same statements and reference; OPTIMIZE FINAL still applies all patches (~3M patch rows read). Granularity is not what the test checks.
e Both directions demonstrated? Yes. CI draw: 300,038 GETs, timeout. Same draw at the floor 1000: 6,038 GETs, 7-8 s. The line fires (20/20 CREATEs got exactly 1000 / 100000) and is load-bearing (corrupted line: raw draws came through).
f Fix is general across code paths? Both patch formats (v1, v2) measured; Compact and Wide parts both occur in the 50/50 soak; the final SELECT is bounded by the same clamp.
g Fix generalizes across inputs (params/datatypes/wrappers)? Both granularity bounds are clamped (the bytes floor alone gives 21-row patch granules); 50/50 randomized on S3 and 50/50 on local disk, granularity 1000..64.7k.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? N/A (test-only change; the runner applies the clamp before building the client command line).

Session id: cron:clickhouse-impl-slot-4:20261010-024000

@clickhouse-gh

clickhouse-gh Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ecf8883]

Summary: ✅


AI Review

Summary

The PR sets lower bounds of 8192 rows and 10485760 bytes for randomized granularity in 03100_lwu_30_join_cache, avoiding excessive patch granules while preserving the workload, assertions, and randomization above those bounds. The runner applies both limits before injecting the settings into CREATE TABLE. Prior CI failures and the author's documented S3 and ThreadFuzzer replays support the change. No actionable findings.

Missing context / blind spots
  • ⚠️ CI for the latest head is still running; the S3 and flaky-check results for the final bounds are not yet available. Completed results would close this verification gap. No local server tests were run during this review.
Final Verdict

✅ Approve. No review changes requested; normal CI completion remains pending.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 72c0c58

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_lightweight_update_pending_rename flaky, hit the 60 s per-test cap while waiting on ALTER TABLE t_lwu_rename_after DELETE WHERE 0 SETTINGS mutations_sync = 2 after SYSTEM START MERGES (1 failure in 30 days; this PR only changes 03100_lwu_30_join_cache.sql, which is no-fasttest) a fix task is created (investigating at full effort, fixing-PR link to follow here)
Mergeable Check, PR rollups of the row above a fix task is created (the one above)

Session id: cron:our-pr-ci-monitor:20261010-090002

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for 05227_lightweight_update_pending_rename (Fast test arm_darwin timeout) created: #125070

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai is this PR still needed?

@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Yes, it is still needed. The test is unchanged on master and keeps timing out on the arm_binary ... s3 storage, sequential lanes whenever the randomizer draws a tiny index_granularity: 5 failures in the last 30 days, all PR runs, and the runner's diagnosis isolated index_granularity 20, 9, 15, 4 and 2. The newest one was yesterday on your #128707 (index_granularity 2):

Master runs these lanes about 8x less often and has no failure yet, but its slowest run there already took 270 s. With the clamp from this PR (index_granularity >= 1000), the replayed failing draws finish in about 10 s instead of timing out.

@PedroTadim
PedroTadim enabled auto-merge November 3, 2026 16:44
The amd_binary flaky check runs the test under ThreadFuzzer, where the merge
takes about 5x its CPU time. A draw at the old floor (index_granularity 1000)
spent 169 s in OPTIMIZE FINAL and 184.9 s in total, over the 180 s per-run
limit. The merge time follows the granule count, and at the old
index_granularity_bytes floor of 100000 the patch parts (44 bytes per row) are
cut into ~2300-row granules, so both floors move to the defaults.

Failing job: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=125032&sha=e84b91cb3e22a91e879603c3fb43274ca170d117&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20flaky%20check%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
auto-merge was automatically disabled November 3, 2026 20:36

Head branch was pushed to by a user without write access

@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

The amd_binary flaky check at e84b91c failed with Test runs too long (> 180s) (report). That check runs under ThreadFuzzer, and a draw at the old floor (index_granularity = 1000) spent 169 s in OPTIMIZE FINAL. I raised both floors to the defaults in ecf8883; a local ThreadFuzzer replay of that draw now takes a quarter of the time (numbers in the description).

@PedroTadim
PedroTadim added this pull request to the merge queue Nov 4, 2026
Merged via the queue into ClickHouse:master with commit 2e11b2f Nov 4, 2026
185 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 4, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). label Nov 22, 2026
@clickhouse-gh clickhouse-gh Bot removed the comp-testing Test content only (no production code). 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-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet 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