Skip to content

Relax per-test flaky-check timeout from 180s to 300s - #106034

Closed
groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/relax-flaky-check-timeout
Closed

groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/relax-flaky-check-timeout

Conversation

@groeneai

Copy link
Copy Markdown
Collaborator

Follow-up to #76867 per @alexey-milovidov directive.

The TEST_MAX_RUN_TIME_IN_SECONDS cap in tests/clickhouse-test fires only in
--flaky-check mode (with --test-runs > 1 and tests not tagged long). At
180s it was too tight for randomized debug-build runs.

CIDB data (30 days, check_name LIKE '%flaky check%' AND test_context_raw LIKE '%runs too long%'):

Duration bucket Count Share
180-240s 170 64%
240-300s 26 10%
300-360s 30 11%
360-480s 26 10%
>480s 14 5%
Total 266 100%

64% of all trips were in the marginal 180-240s range. The 4 historical
02352_lightweight_delete trips on PR #76867 are 185s, 199s, 222s, 243s, all
under unlucky randomized combos (--max_insert_threads {1,2,3} +
enable_parallel_replicas 1 + page_cache_inject_eviction True on the 1M-row
debug insert). With 300s the cap still catches the 74 historical trips at
300s+ (p95 = 483s) while removing the marginal false positives.

The constant is the only consumer (only used by the failure message and the
single flaky_check check at the end of TestCase.process_result_impl),
so a single-line bump is sufficient.

Also update the stale 180s reference in 01114_database_atomic.sh to
refer to the constant by name so the next bump does not need a paired edit.

CI report referenced in the directive: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=76867&sha=b27932443a4b9a7c5e08fb381274ad9b2b0658e5&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29

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

...

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (session: cron:clickhouse-ci-task-worker:20260528-111500)

a) Deterministic trigger? Yes. The cap fires exactly when flaky_check AND test_runs > 1 AND total_time > 180s AND "long" not in tags. CIDB shows 266 occurrences across 30 days.

b) Root cause explained? Yes. The 180s budget is consumed by marginal randomized combos on debug builds. For 02352_lightweight_delete: 1M-row INSERT under --max_insert_threads {1,2,3} plus enable_parallel_replicas 1 plus parallel_replicas_for_non_replicated_merge_tree 1 plus page_cache_inject_eviction True consistently hits 185-243s. Each ingredient adds debug-instrumented overhead; together they push a functionally-correct test just over the cap.

c) Fix matches root cause? Yes. Raising the threshold to 300s gives the marginal randomized configs enough headroom (all 4 historical trips fall under 300s) while keeping the cap in place for the genuinely-slow tail.

d) Test intent preserved? Yes. The cap still exists and still trips for tests that are actually too slow. 26% of historical "too long" trips (70 in 30 days, p95 = 483s) remain caught at 300s. The "Make it faster" gate continues to apply.

e) Demonstrated in both directions? The change is data-driven from CIDB: at 180s the test family trips 266 times, at 300s it would trip 70 times. No local reproduction is needed because the failure shape is the comparison total_time > TEST_MAX_RUN_TIME_IN_SECONDS, not a behavior bug; the constant directly controls the trip condition.

f) Fix is general, not a narrow patch? Yes. This is the broader --flaky-check-mode timeout requested by @alexey-milovidov in #76867 (comment) ("the broader 'relax the timeout for flaky check runs' option") rather than per-test long tag or per-test setting pin.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov for review per your #76867 (comment) directive. The change is the per-test TEST_MAX_RUN_TIME_IN_SECONDS bump from 180s to 300s (flaky-check-mode only); the second touched file just refreshes a stale literal-180s reference in a test comment.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6b690f8]


AI Review

Summary

This PR raises the clickhouse-test flaky-check per-test limit from 180s to 300s and updates one test comment to avoid hard-coding the old cap. The code path remains scoped to --flaky-check, repeated runs, and tests without the long tag. I found one low-severity consistency issue in nearby test comments; no blocking correctness concerns.

Findings

💡 Nits

  • [tests/clickhouse-test:130] The cap is now 300, but stale flaky-check comments still refer to a 180s timeout or budget in tests/queries/0_stateless/01903_csvwithnames_subset_of_columns.sh:14 and tests/queries/0_stateless/04070_s3_disk_settings_override.sh:8,11. Update those comments too, or phrase them in terms of TEST_MAX_RUN_TIME_IN_SECONDS, so future tag/rationale decisions do not use the old limit.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 28, 2026
Comment thread tests/clickhouse-test
# Applies only in `--flaky-check` mode. Tests tagged `long` are exempt.
# 180s was too tight for randomized debug-build runs (e.g. `--max_insert_threads`
# combined with `enable_parallel_replicas` + `page_cache_inject_eviction`).
TEST_MAX_RUN_TIME_IN_SECONDS = 300

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.

Now that TEST_MAX_RUN_TIME_IN_SECONDS is 300, there are still flaky-check comments that describe the timeout or budget as 180s: tests/queries/0_stateless/01903_csvwithnames_subset_of_columns.sh:14 and tests/queries/0_stateless/04070_s3_disk_settings_override.sh:8,11. This PR already removes the stale literal from 01114_database_atomic.sh; please update the remaining references too, or phrase them in terms of TEST_MAX_RUN_TIME_IN_SECONDS, so future tag/rationale decisions do not keep using the old cap.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, addressed in 15da082896a0. Replaced the literal 180s with backticked TEST_MAX_RUN_TIME_IN_SECONDS references in the two flagged files, plus two more that had the same pattern:

  • 01903_csvwithnames_subset_of_columns.sh:14 (flagged)
  • 04070_s3_disk_settings_override.sh:8,11 (flagged)
  • 02435_rollback_cancelled_queries.sh:5 (also 180s default budget; also clarified that the 600s budget is the separate --timeout per-test cap)
  • 02475_bson_each_row_format.sh:3 (more than 180 seconds justifying the long tag)

Left alone the two unrelated 180s references that describe the server-side SystemLogBase waitFlush deadline (a separate constant in C++ source), not the flaky-check cap:

  • 02818_memory_profiler_sample_min_max_allocation_size.sh:4
  • 03096_order_by_system_tables.sql:5

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 28, 2026
…TIME_IN_SECONDS

Follow-up to clickhouse-gh[bot] inline review on PR ClickHouse#106034. The bot flagged
01903_csvwithnames_subset_of_columns.sh:14 and 04070_s3_disk_settings_override.sh:8,11
as still using the literal '180s' to describe the flaky-check per-test budget. Same
pattern as the 01114_database_atomic.sh update already in this PR: replace the literal
with a backtick reference to the `clickhouse-test` constant
`TEST_MAX_RUN_TIME_IN_SECONDS`, so future bumps of the cap do not leave behind stale
literals across test-comment rationale.

Two additional files were updated for the same reason:
- 02435_rollback_cancelled_queries.sh:5 - 'exceeds the 180s default budget' was the
  same flaky-check cap; clarified that the 600s budget is the `--timeout` (regular
  per-test cap), which is a separate constant and stays correct.
- 02475_bson_each_row_format.sh:3 - 'more than 180 seconds' was the same flaky-check
  cap, justifying the `long` tag.

Two remaining 180s references in tests/queries/0_stateless/ were intentionally left
alone, because they describe the server-side `SystemLogBase` `waitFlush` deadline
(a separate 180s constant in C++ source), not the flaky-check cap:
- 02818_memory_profiler_sample_min_max_allocation_size.sh:4
- 03096_order_by_system_tables.sql:5
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 28, 2026
groeneai added 2 commits June 11, 2026 00:29
The 180s `TEST_MAX_RUN_TIME_IN_SECONDS` cap in `tests/clickhouse-test` is
enforced only in `--flaky-check` mode (with `--test-runs > 1` and tests not
tagged `long`). It was too tight for randomized debug-build runs: 64% of the
266 `Test runs too long (> 180s)` failures across 30 days fell in the marginal
180-240s range, dominated by combinations of `--max_insert_threads`,
`enable_parallel_replicas`, `parallel_replicas_for_non_replicated_merge_tree`,
and `page_cache_inject_eviction` on multi-million-row debug tests.

The 4 historical `02352_lightweight_delete` flaky-check trips on PR ClickHouse#76867
were 185-243s; all fall under 300s.

Bumping to 300s keeps the cap meaningful (74 historical failures over 30 days
still trip, p95 of the trip distribution is 483s) while removing the false
positives that just need a few more seconds under unlucky randomized configs.

Update the stale `180s` reference in `01114_database_atomic.sh` to reference
the constant by name so future bumps do not require an additional edit.

Follow-up to ClickHouse#76867
…TIME_IN_SECONDS

Follow-up to clickhouse-gh[bot] inline review on PR ClickHouse#106034. The bot flagged
01903_csvwithnames_subset_of_columns.sh:14 and 04070_s3_disk_settings_override.sh:8,11
as still using the literal '180s' to describe the flaky-check per-test budget. Same
pattern as the 01114_database_atomic.sh update already in this PR: replace the literal
with a backtick reference to the `clickhouse-test` constant
`TEST_MAX_RUN_TIME_IN_SECONDS`, so future bumps of the cap do not leave behind stale
literals across test-comment rationale.

Two additional files were updated for the same reason:
- 02435_rollback_cancelled_queries.sh:5 - 'exceeds the 180s default budget' was the
  same flaky-check cap; clarified that the 600s budget is the `--timeout` (regular
  per-test cap), which is a separate constant and stays correct.
- 02475_bson_each_row_format.sh:3 - 'more than 180 seconds' was the same flaky-check
  cap, justifying the `long` tag.

Two remaining 180s references in tests/queries/0_stateless/ were intentionally left
alone, because they describe the server-side `SystemLogBase` `waitFlush` deadline
(a separate 180s constant in C++ source), not the flaky-check cap:
- 02818_memory_profiler_sample_min_max_allocation_size.sh:4
- 03096_order_by_system_tables.sql:5
@groeneai
groeneai force-pushed the groeneai/relax-flaky-check-timeout branch from 15da082 to feef6a9 Compare June 11, 2026 00:31
@Algunenano Algunenano self-assigned this Jun 11, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand the point of this change. Tests are clustering around the 180s mark because that was the limit that we put when we introduced the check. If we raise it to 300s, then tests will cluster around the 300s mark. This isn't solving anything.

The proper fix is to fix old tests by making them faster. Also, failures in flaky check are good since it's surfacing existing issues. This is just hiding them so we don't see slow CI

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, and you're right. Bumping the cap from 180s to 300s just moves the clustering to the new limit and hides slow CI rather than fixing it. The flaky-check surfacing slow tests is the point of the check, not noise to suppress.

Closing this PR. The right fix is per-test: make the genuinely slow tests faster, or tag legitimately heavy tests long (which both reduces their flaky-check repeat count and exempts them from the per-test cap). The specific test that triggered the original follow-up request (02352_lightweight_delete, slow since minmax indices became default in #76867) is tracked separately and will be addressed there.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Closing per @Algunenano's review: the global flaky-check timeout bump is the wrong approach. Right fix is per-test (make slow tests faster or tag heavy ones long).

@groeneai groeneai closed this Jun 11, 2026
@Algunenano

Copy link
Copy Markdown
Member

Closing this PR. The right fix is per-test: make the genuinely slow tests faster, or tag legitimately heavy tests long (which both reduces their flaky-check repeat count and exempts them from the per-test cap). The specific test that triggered the original follow-up request (02352_lightweight_delete, slow since minmax indices became default in #76867) is tracked separately and will be addressed there.

@groeneai Notice how things are working properly: If #76867 is the PR making this test slower and the CI is detecting this, then that PR CI should be red and not merged

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 manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants