Skip to content

Speed up four tests that exceed 180 s in the flaky check - #125263

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:speed-up-four-flaky-check-slow-tests
Oct 15, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:speed-up-four-flaky-check-slow-tests

Conversation

@groeneai

@groeneai groeneai commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115050

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 (CI fix).

Description

#115050 only edits the Tags line of four tests, and its flaky check fails all four with Test runs too long (> 180s) across amd_binary, amd_debug and amd_asan_ubsan (amd_binary report). Any PR that touches them gets this red. The flaky check runs each test 50 times on 8 workers under the ThreadFuzzer environment, which clickhouse-local also inherits since 6b62ea4. Each test has one dominant cost:

  • 03173_row_binary_and_native_with_binary_encoded_types: 228 clickhouse-local launches. One process now encodes all values with INTO OUTFILE, another decodes them with file(). Reference unchanged.
  • 04073_parallel_replicas_in_order_splits: OPTIMIZE TABLE ... FINAL took 193-209 s of each run and only rewrote the single part the INSERT had already made (1e6 rows fit in one insert block). It is replaced by a check that there is exactly one active part.
  • 00564_versioned_collapsing_merge_tree: the two 1000000-row sections print nothing and took 151-169 s of each ASan run. They now use 200000 rows, and the vertical-merge section sets min_bytes_for_wide_part = 0 so it still merges Wide parts vertically.
  • 00223_shard_distributed_aggregation_memory_efficient: the analyzer folds randConstant() % 2 ? 5 : 10 on the initiator, so both shards always got the same filter, and the 10 repetitions per block never covered shards reading different key sets. Each block now runs the four per-shard combinations once via shardNum(), with exact expected values.

No long tags: that would drop these tests from --no-long jobs. The Tags lines are untouched, so this merges cleanly with #115050.

Validation: 50 randomized runs of each test pass on debug and ASan, and the new checks fail when their condition is broken. Under the ThreadFuzzer environment on one machine with the same binary, the per-run time drops 1.6x for 00564 under ASan and 2.6-18x for the other three (lower bounds for 03173 and 04073, whose old runs hit the 600 s timeout).


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

Version info

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

The flaky check runs each changed test 50 times on 8 workers with the
ThreadFuzzer environment, which `clickhouse-local` also inherits since
6b62ea4. Four tests then exceed the 180 s per-run limit:

- 03173: 228 `clickhouse-local` launches. Encode all values in one
  process with `INTO OUTFILE` and decode them in another with `file()`.
  The reference is unchanged.
- 04073: `OPTIMIZE ... FINAL` only rewrote the single part the INSERT
  already produced. Drop it and assert that there is one active part.
- 00564: the 1000000-row sections print nothing. Use 200000 rows, and
  keep the vertical-merge section's parts Wide (`min_bytes_for_wide_part
  = 0`) so it still merges vertically.
- 00223: the analyzer folds `randConstant()` on the initiator, so both
  shards always read the same key set and the 10 repetitions per block
  never covered shards with different keys. Run the four per-shard key
  combinations once each via `shardNum()` and check exact values.

Related: ClickHouse#115050

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 11, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)
Finding Verdict
⚠️ 00564: at 200000 rows the vertical-merge section's parts were Compact, so its OPTIMIZE FINAL merged horizontally AGREE, fixed: that table sets min_bytes_for_wide_part = 0 (server log: into Wide, Selected MergeAlgorithm: Vertical, 100 of 100 randomized runs)
⚠️ 00564: no assertion that the merge is vertical DISAGREE: master's file has none either; the pin cannot be randomized away (no-random-merge-tree-settings)
⚠️ 00223: random group_by_two_level_threshold_bytes can make both shards two-level DISAGREE: same on master; it draws 1 in ~20% of runs, the other runs keep the single/two-level mix, and the results do not depend on it
💡 03173: the no-fasttest justification ("many new processes") is stale Noted, not blocking: line 3 is next to the Tags line #115050 edits, so changing it here would conflict

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for this duration verdict: the old files fail every flaky-check run of a PR that touches them (#115050 @ 35a88c5 on amd_binary, amd_debug, amd_asan_ubsan; also #95071, #122537, #94017), and 8 of 8 runs per test locally with the CI ThreadFuzzer environment and --flaky-check --test-runs 8 -j 8.
b Root cause explained? The flaky check exports THREAD_FUZZER_* for the whole job, and clickhouse-local inherits it since 6b62ea4. Per test, one cost dominates (from the failing jobs' query_log, part_log and xtrace): 228 clickhouse-local launches (03173), an OPTIMIZE FINAL that rewrites the only part (04073, 193-209 s), two 1000000-row sections that print nothing (00564, 151-169 s under ASan), 90 distributed queries whose randConstant() the analyzer folds on the initiator (00223).
c Fix matches root cause? Yes: each change removes that cost. No long tag, no widened bound, no no-random-* tag, no CI or src/ change.
d Test intent preserved / new tests added? 03173 and 00564 references are byte-identical. 04073 keeps every check and adds parts 1, the precondition OPTIMIZE used to establish. 00223 now covers shards reading different key sets, which had not run since the analyzer became the default. 00564's vertical-merge section still merges Wide parts vertically (min_bytes_for_wide_part = 0, checked in the server log).
e Both directions demonstrated? Same machine, same binary, ThreadFuzzer environment: old debug p50 489 s (00223), at least 600 s (03173, 04073, killed); new 176 s, 228 s, 32 s. 00564: ASan p50 264 s -> 168 s; on debug its 200000-row sections take 45 s per run instead of 123 s, but the whole run varies 325-410 s between identical old runs. Oracles are live: 03173 without the decode flag fails 3/3, 00223 with randConstant() restored fails 3/3 on the mixed lines, 04073 with min_insert_block_size_rows = 100000 (9-10 parts) fails 3/3.
f Fix is general across code paths? N/A (test-only). Other tests that launch many clickhouse-local processes are slowed the same way since 6b62ea4; none of them failed here, so they are not changed.
g Fix generalizes across inputs (params/datatypes/wrappers)? 50 randomized runs of each test pass on debug and ASan (500 of 500), plus runs without randomization. 04073 holds one part for max_insert_threads 1, 2, 3 and 12.
h Backward compatible? (maintainer-approved exception only) Yes: test-only, no setting, format or behaviour change.
i Invariants and contracts preserved? Yes: references unchanged or stronger; the Tags lines are untouched, so the PR merges cleanly with #115050.

Session id: cron:clickhouse-impl-slot-6:20261011-182600

@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d8fa3d9]

Summary: ✅


AI Review

Summary

This PR makes four slow stateless tests cheaper in the flaky check without changing their intended coverage: 00223 replaces randConstant()-based sampling with explicit per-shard cases, 03173 batches the clickhouse-local encode/decode work, 04073 drops a redundant OPTIMIZE ... FINAL and asserts the single-part precondition directly, and 00564 reduces row counts while keeping the vertical-merge setup intact. I reviewed the current diff together with the existing PR discussion and did not find any correctness, test-contract, or PR-metadata issues that warrant an inline finding.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 11, 2026
@groeneai
groeneai requested a review from Avogar October 11, 2026 21:21
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 11, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 5233a9f

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) / 05210_lightweight_update_materialized_cte_in_ignore flaky, not from this PR (it only speeds up 00223, 00564, 03173 and 04073): UNKNOWN_TABLE (Code 60) on the initiator-local materialized CTE table under parallel replicas (issue #112642); 146/146 same-settings reruns passed. 7 days: 149 failures across 138 PRs and 23 on master #123121 (mine, open)
Mergeable Check, PR praktika rollups of the row above #123121 (mine, open)

Session id: cron:our-pr-ci-monitor:20261012-100010

@Avogar Avogar self-assigned this Oct 12, 2026
@Avogar

Avogar commented Oct 12, 2026

Copy link
Copy Markdown
Member

@groeneai chjeck CI and merge master into the branch

@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master in d8fa3d9 (clean, the PR diff is unchanged). CI on the previous head had one failure, 05210_lightweight_update_materialized_cte_in_ignore in the ParallelReplicas job, which these test files do not touch; it is fixed by #123121 (open). CI on the new head is running.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 14, 2026
The removed `OPTIMIZE ... FINAL` used to merge the table into one part.
The INSERT already writes one part: its 131072 rows are below
`min_insert_block_size_rows` and the squashed `LowCardinality` block is far
below `min_insert_block_size_bytes`, so squashing emits a single block.
Neither setting is randomized. The randomized settings that touch this
INSERT (`max_insert_threads`, `max_block_size`,
`optimize_trivial_insert_select`) and `async_insert` still give one part.

Assert the part count instead of relying on it, as ClickHouse#125263 does for 04073.
With `min_insert_block_size_rows = 100000` the INSERT writes two parts and
the test now fails on this line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 15, 2026
Merged via the queue into ClickHouse:master with commit 888cac6 Oct 15, 2026
177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
alexey-milovidov added a commit that referenced this pull request Oct 16, 2026
#125263 reduced the two 1000000-row inserts in this test
to 200000 rows, so it no longer averages over 60 s under MSan. Touching the test made the flaky
check run it, and in the `CH Inc sync` flaky check (`amd_asan_ubsan`, `s3 storage`, `meta in keeper`)
it took 187 s, over the 180 s limit. Leave the file unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Oct 18, 2026
`03173_row_binary_and_native_with_binary_encoded_types`, `04073_parallel_replicas_in_order_splits`,
`00223_shard_distributed_aggregation_memory_efficient` and `04143_low_cardinality_single_dict_read_amplification`
now average well below 60 s under MSan after fixture speedups on `master`
(#125263, #125795).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-testing Test content only (no production code). 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.

4 participants