Skip to content

Give long tests of a flaky check a per-test timeout that matches them - #121387

Merged
alexey-milovidov merged 3 commits into
masterfrom
ci-flaky-check-long-test-timeout
Sep 26, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
ci-flaky-check-long-test-timeout

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

A flaky check hands every worker the same changed test, so one heavy test contends with --jobs N copies of itself instead of with N unrelated tests. clickhouse-test already accounts for that: a test tagged long is exempt from the TEST_MAX_RUN_TIME_IN_SECONDS "too long" verdict of the check. The per-test budget was not exempt, though - proc.wait(args.timeout) killed such a test at the --timeout default of 600s regardless of the tag - so a pull request that merely edits one draws a red that says nothing about the change.

Measured on 03927_autopr_input_bytes_estimation_prewhere_filter, whose p50 under any asan lane on master is 33s and whose p90 is 55s: in the amd_asan_ubsan flaky check it runs in 307-383s and is killed at 600.3s. The inflation is the check's shape rather than a property of the test - in the same job the other five AutoPR estimation tests are 4.1x to 5.6x their own master p50 (03634 66.6s against 16.3s, 04340 27s against 5.7s, 03634_compact 26s against 4.6s, 04838 15s against 3s) - and it has already produced the same 600.3s kill on pull requests that have nothing in common: #96844, #119350 and #100736.

TestCase.get_timeout now gives a long test of a flaky check FLAKY_CHECK_LONG_TEST_TIMEOUT_MULTIPLIER times --timeout - but only when it runs in the parallel worker pool without --no-self-parallel, i.e. where copies of it can actually contend with each other; the targeted check and the sequential runner keep --timeout - and is the single place the per-test budget is read: the wait, the cleanup budget, the worker's upper-level alarm, and CLICKHOUSE_TEST_TIMEOUT for a .sh test that budgets itself against the harness. Every other test and every other job keeps --timeout unchanged, so the 600s net still catches a new test that is merely slow, and the 180s TEST_MAX_RUN_TIME_IN_SECONDS verdict still fails one that is not tagged long.

The external safety net in run_tests has to stay above the graceful alarm it exists to avoid pre-empting, so it is now derived from the same numbers instead of being a written-out 900s. For a job that is not a flaky check the derivation yields exactly the 900s it has always been; for a flaky check without --no-self-parallel it yields 2220s, still far below the 2.5h job timeout.

Related: #96844

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

🤖 Generated with Claude Code


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

Version info

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

A flaky check hands every worker the *same* changed test, so one heavy test
contends with `--jobs N` copies of itself instead of with N unrelated tests.
`clickhouse-test` already accounts for that: a test tagged `long` is exempt from
the `TEST_MAX_RUN_TIME_IN_SECONDS` "too long" verdict of the check. The per-test
budget was not exempt, though - `proc.wait(args.timeout)` killed such a test at
the `--timeout` default of 600s regardless of the tag - so a pull request that
merely edits one draws a red that says nothing about the change.

Measured on `03927_autopr_input_bytes_estimation_prewhere_filter`, whose p50
under any `asan` lane on master is 33s and whose p90 is 55s: in the
`amd_asan_ubsan` flaky check it runs in 307-383s and is killed at 600.3s. The
inflation is the check's shape rather than a property of the test - in the same
job the other five AutoPR estimation tests are 4.1x to 5.6x their own master
p50 - and it has already produced the same 600.3s kill on pull requests that
have nothing in common: #96844, #119350 and #100736.

`TestCase.get_timeout` now gives a `long` test of a flaky check
`FLAKY_CHECK_LONG_TEST_TIMEOUT_MULTIPLIER` times `--timeout`, and is the single
place the per-test budget is read: the wait, the cleanup budget, the worker's
upper-level alarm, and `CLICKHOUSE_TEST_TIMEOUT` for a `.sh` test that budgets
itself against the harness. Every other test and every other job keeps
`--timeout` unchanged.

The external safety net in `run_tests` has to stay above the graceful alarm it
exists to avoid pre-empting, so it is now derived from the same numbers instead
of being a written-out 900s. For a job that is not a flaky check the derivation
yields exactly the 900s it has always been; for a flaky check it yields 2220s,
still far below the 2.5h job timeout.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d2b3a90]

Summary: ✅


AI Review

Summary

This PR fixes the original false-positive 600s timeout for long tests in flaky checks by plumbing a larger per-test budget through clickhouse-test and the functional-test wrapper. I found one remaining contract gap: the new multiplier is keyed to "parallel worker path" rather than actual peer contention, so once the flaky pool has effectively serialized itself, later long tests still receive the 3x budget and can dilute the 20/45-minute signal.

Findings
  • ⚠️ [tests/clickhouse-test:3170-3175] get_timeout uses self.is_concurrent as a proxy for self-contention, but that flag stays true for tests taken from the shared flaky-check queue even after do_run_tests sheds workers down to one under memory pressure (tests/clickhouse-test:6191). The same false positive exists for a flaky run forced to --jobs 1. In both cases a long test still gets 3 * --timeout even though no peer copy can run beside it, so a single wedged run can still consume another 30 minutes and weaken the flaky/merge-queue verdict. Suggested fix: make the multiplier depend on the current active-worker count, or pass an explicit can_self_contend flag that is cleared once the pool serializes.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: apply the long flaky-check multiplier only while the selected test can still contend with peer copies in the live worker pool.

LLVM Coverage Report

Measured on commit d2b3a90.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 79.50% 79.50% +0.00%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +201 lines in 52 files (-120 lines lost coverage) · Details

Full report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 21, 2026
Comment thread tests/clickhouse-test Resolved
alexey-milovidov and others added 2 commits September 26, 2026 04:43
…elves

Address review: `--flaky-check` also covers the targeted check, which passes
`--no-self-parallel`, and the sequential runner, and neither of them ever runs
concurrent copies of the same test. Give the multiplied budget only to a
`long` test run by the parallel workers without `--no-self-parallel`, and size
the external safety net in `run_tests` by the same condition, so the targeted
check keeps the 900s margin it has always had.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). and removed comp-testing Test content only (no production code). labels Sep 26, 2026
Comment thread tests/clickhouse-test
if (
args.flaky_check
and not args.no_self_parallel
and self.is_concurrent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.is_concurrent is only "this test came from the parallel queue", not "this test still has peer copies that can contend with it". In do_run_tests the flaky-check pool can shed workers under memory pressure until only one process remains (tests/clickhouse-test:6191), and a local flaky run can start at --jobs 1 too. In both cases later long tests still match this predicate and get 3 * --timeout even though they now run alone.

That breaks the contract from the docstring: once the pool has serialized itself there is no self-contention to compensate for, but one wedged long test can still consume another 30 minutes and weaken the 20/45-minute flaky-check signal. The multiplier needs to follow the current ability to run peer copies concurrently, not just whether the test originally came from the parallel worker path.

@alexey-milovidov alexey-milovidov self-assigned this Sep 26, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 26, 2026
Merged via the queue into master with commit 8c04d26 Sep 26, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the ci-flaky-check-long-test-timeout branch September 26, 2026 21:44
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 26, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 27, 2026
ClickHouse#121387 made `run_single_test` call `get_timeout`, which reads `flaky_check`
and `no_self_parallel` from the test case arguments and `is_concurrent` from
the test case. The stand-in built by `make_case` had none of them, so
`run_single_test` raised `AttributeError` before it reached the replaced
`Popen`, and the test failed in the merge queue with a `TypeError` on `seen`.

With the attributes set to their defaults the test passes against the merged
runner again, and against master's runner (without the spawn change) all seven
reference lines still differ.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=gh-readonly-queue/master/pr-112265-00721e1919652f65821d92356b3d8eea5848f8d2&sha=3b6d2a99a5abb1aa1963c91a8df6d403053f2eeb&name_0=MergeQueueCI&name_1=Fast%20test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-testing Test content only (no production code). and removed comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-testing Test content only (no production code). 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.

2 participants