Skip to content

Widen timing thresholds in 04053_merge_table_large_query_performance - #104275

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04053-flaky-timing-assertion
May 7, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04053-flaky-timing-assertion

Conversation

@groeneai

@groeneai groeneai commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

The stateless test 04053_merge_table_large_query_performance is chronically flaky. It asserts that a Merge-table query is no more than 10x slower than the equivalent single-table query, with a 10s max_execution_time on each timed run. Both bounds are too tight under parallel CI noise: the single-table run is fast (~250-400ms) so small absolute jitter produces large ratio swings, and 10s leaves no margin when the runner is loaded.

Recent CIDB evidence (30-day window, 8 failures across 5 unrelated PRs + 1 master hit on 2026-05-05) shows the test failing in two ways:

  • Ratio just over the threshold: 10.3x, 10.3x, 13x, 16x.
  • Per-query timeout: 11s, 13s.

This PR widens the ratio threshold from 10x to 20x and the per-query max_execution_time from 10s to 30s. The original O(N * query_complexity) regression that this test catches (issue #32465) would scale to ~100x-200x slowdown at N=200 underlying tables, so 20x still detects it comfortably and 30s easily catches the multi-tens-of-seconds runtime that bug produced.

Sample failing CI report:

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.412

The test asserts that the `Merge`-table query is no more than 10x slower
than the equivalent single-table query, with a 10s `max_execution_time`
on each timed run. Both bounds are too tight under parallel CI noise:
the single-table run is fast (~250-400ms) so small absolute jitter
produces large ratio swings, and 10s leaves no margin when the runner
is loaded.

Recent CI evidence (8 failures across 5 unrelated PRs + 1 master hit
in 30 days) shows ratios ranging 10.3x-16x and merge-side timeouts of
11-13s — all just barely over the existing thresholds.

Widen the ratio to 20x and the per-query `max_execution_time` to 30s.
The original O(N * query_complexity) regression that this test was
written to catch (issue ClickHouse#32465) would scale to ~100x-200x slowdown at
N=200 underlying tables, so 20x still detects it comfortably.

Session: cron:clickhouse-ci-task-worker:20260507-021500
@groeneai

groeneai commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (per worker policy):

  • (a) Deterministic repro? No — wall-clock timing tests aren't reproducible on a single workstation. CIDB historical data substitutes: 8 documented failures across 5 unrelated PRs + 1 master hit in 30 days, with ratios 10.3x / 10.3x / 13x / 16x and per-query timeouts of 11s and 13s.
  • (b) Root cause? The single-table timed run is fast (~250-400ms). Small absolute jitter on the runner produces large ratio swings against a fixed merge-side cost. The 10s max_execution_time also leaves no margin when the runner is loaded.
  • (c) Fix matches root cause? Yes — widening to 20x absorbs the observed worst case (16x) with 25% margin; widening the timeout to 30s absorbs the observed worst case (13s) with >2x margin.
  • (d) Test intent preserved? Yes — the original O(N * query_complexity) regression at N=200 would produce a 100x-200x slowdown, well above the 20x threshold and well above 30s.
  • (e) Both directions demonstrated? Local debug build confirms the test still passes (4.10s, 3.70s wall clock). Cannot synthesize CI noise locally; CIDB shows all 8 historical failures would have passed at 20x / 30s.

Session: cron:clickhouse-ci-task-worker:20260507-021500

@groeneai

groeneai commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — could you review this? It widens the 10x ratio and 10s timeout in 04053 to 20x / 30s after 8 documented failures across 5 unrelated PRs + 1 master hit, all just barely over the existing thresholds. Original O(N * query_complexity) regression at N=200 (~100x-200x slowdown) is still detected.

@Algunenano Algunenano self-assigned this May 7, 2026
@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label May 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [779607f]

Summary: ✅


AI Review

Summary

This PR adjusts the flaky stateless performance test 04053_merge_table_large_query_performance by increasing both timed-query max_execution_time (10s → 30s) and the merge-vs-single slowdown threshold (10x → 20x). I found no correctness, safety, or compliance issues in the change, and the updated bounds remain capable of detecting the historical severe regression this test targets.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 7, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 7, 2026
Merged via the queue into ClickHouse:master with commit d7e9f86 May 7, 2026
165 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 May 7, 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 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