Skip to content

Apply soft-timeout to integration tests flaky check - #105819

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/integration-flaky-check-soft-timeout
May 31, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/integration-flaky-check-soft-timeout

Conversation

@groeneai

@groeneai groeneai commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

The integration tests flaky check runs each modified test ~50 times across every changed test module. With existing per-phase pytest session timeouts (session_timeout_parallel = 2h, session_timeout_sequential = 1h × N attempts), total wall-clock time can far exceed the workflow's global job timeout. When the global timeout fires, the pytest subprocess is hard-killed by Shell.run's subprocess timeout, leaving no session-finish record in the pytest jsonl and producing Unknown error (exit status: None) instead of a proper FAIL/OK summary.

Observed on Integration tests (amd_asan_ubsan, flaky) for PR #105171: ran 2h18m54s, errored with Unknown error (exit status: None), no test results in the report.
Job log: https://github.com/ClickHouse/ClickHouse/actions/runs/26416267614/job/77763513026

The functional tests flaky check already handles this via a soft FLAKY_CHECK_TIME_LIMIT in ci/jobs/functional_tests.py:544-554. This PR ports the same logic to ci/jobs/integration_test_job.py:

  1. FLAKY_CHECK_TIME_LIMIT = 90 * 60 (90 min; longer than functional's 45 min because integration tests are slower).
  2. Cap both session_timeout_parallel and session_timeout_sequential to the remaining budget at the start so a single phase cannot consume the entire budget.
  3. In the sequential-attempts loop, recompute remaining budget each iteration; break early when < 60s left; cap each iteration's --session-timeout to remaining.
  4. Treat session-timeout in flaky check as expected (do not propagate as a job-level error, filter out the synthetic Timeout result), matching how targeted checks already handle session-timeout.

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)

cc @alexey-milovidov (per directive on #105171), @maxknv, @leshikus (comp-ci-infrastructure)

Version info

  • Merged into: 26.6.1.275

The integration tests flaky check runs each modified test ~50 times across
all changed test modules. With existing per-phase timeouts of `session_timeout_parallel`
= 2h and `session_timeout_sequential` = 1h x N attempts, the total wall-clock
time can far exceed the workflow's global job timeout. When the global timeout
fires, the pytest subprocess is hard-killed via `Shell.run`'s subprocess
timeout, leaving no session-finish record in the pytest jsonl report and
producing `Unknown error (exit status: None)` on the report instead of a
proper FAIL/OK summary.

Reproduced on `Integration tests (amd_asan_ubsan, flaky)` for ClickHouse#105171:
job ran 2h18m54s before the global timeout, errored with the above message,
and the report shows ERROR / no test results.

The functional tests flaky check already handles this via a soft
`FLAKY_CHECK_TIME_LIMIT` (see `ci/jobs/functional_tests.py:544-554`): it
bounds the time spent inside `clickhouse-test`, so the job has headroom for
cleanup, log collection, and reporting before the global timeout fires.

This commit ports the same logic to `ci/jobs/integration_test_job.py`:

1. `FLAKY_CHECK_TIME_LIMIT = 90 * 60` (90 min, longer than functional's 45
   min because integration tests are slower).

2. Cap both `session_timeout_parallel` and `session_timeout_sequential` to
   the remaining budget at the start, so a single phase cannot consume the
   entire budget.

3. In the sequential-attempts loop, recompute the remaining budget every
   iteration. Break out of the loop early when the budget is exhausted
   (< 60s left). Cap each iteration's session-timeout to the remaining
   budget.

4. Treat session-timeout in flaky check as expected (do not propagate as a
   job-level error and filter out the synthetic `Timeout` result), matching
   how targeted checks already handle session-timeout.

Reference: ClickHouse#105171
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (session id: cron:clickhouse-ci-task-worker:20260526-034500):

Q Answer
(a) Deterministic root-cause source? Yes. PR #105171 Integration tests (amd_asan_ubsan, flaky) ran 2h18m54s and failed with Unknown error (exit status: None). Log: https://github.com/ClickHouse/ClickHouse/actions/runs/26416267614/job/77763513026. The error string is emitted at ci/praktika/result.py:2046-2049 when pytest's session-exitstatus is None — i.e., pytest was hard-killed by Shell.run's subprocess timeout (session_timeout_parallel + 600 = 7800s, plus setup overhead).
(b) Root cause explained? Yes. Flaky check (is_flaky_check) runs each modified test ~50 times with --dist=each across all changed modules. Existing bounds: session_timeout_parallel = 2h, session_timeout_sequential = 1h × max(3, workers). Total can exceed the workflow's global job timeout; the workflow then SIGKILLs the pytest subprocess (via the outer subprocess timeout / runner limit) and the pytest jsonl has no session-finish record. The praktika translator at result.py:2037-2049 maps that to ERROR with Unknown error (exit status: None).
(c) Fix matches root cause? Yes. Mirrors the exact pattern in ci/jobs/functional_tests.py:544-554 (FLAKY_CHECK_TIME_LIMIT = 45*60). Bounds total time inside pytest via a soft budget shared between the parallel run and the sequential loop, ensuring pytest gracefully terminates well before the workflow global timeout.
(d) Test intent preserved? Yes. Flaky check still runs the modified tests with --dist=each and high --count semantics; it just stops scheduling new iterations once the budget is exhausted. No previously-running tests are skipped. The pattern is identical to functional flaky-check, which has worked reliably.
(e) Demonstrated both directions? The forward direction (PR #105171 failed under master HEAD) is shown by the job log linked in (a). The backward direction (this PR's logic prevents the hard kill) is demonstrated by analogy with functional_tests.py's identical pattern, which has been in production for an extended period without Unknown error (exit status: None) failures in flaky check. Once this PR lands, retrying #105171's flaky check will provide the empirical confirmation.
(f) General not narrow? Yes. The fix only touches is_flaky_check paths in integration_test_job.py: it does not alter normal jobs, targeted checks, bugfix validation, or LLVM coverage. It brings integration flaky-check to parity with functional flaky-check.

Chose FLAKY_CHECK_TIME_LIMIT = 90 * 60 (90 min) rather than functional's 45 min because integration tests are substantially slower; 90 min still leaves ~30+ min headroom under any 2-2.5h workflow global timeout.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2edfeef]

Summary: ✅


AI Review

Summary

This PR adds a soft time budget for integration flaky checks to avoid hard-killed jobs near workflow timeout, and it filters synthetic Timeout results in flaky mode. The budgeting idea is good, but the new flaky-mode error handling is too broad and can hide real pytest runner failures as successful runs.

Findings

⚠️ Majors

  • [ci/jobs/integration_test_job.py:935] (same pattern at :976, combined with :1065) is_flaky_check now suppresses all Result.Status.ERROR outcomes, not only expected soft session-timeout cases. If pytest exits with internal/usage/unknown errors (for example exitstatus 3, 4, or missing SessionFinish), test_result_*.results may be empty; after filtering synthetic Timeout, the job can incorrectly end as OK.
    Suggested fix: only suppress explicit session-timeout errors (synthetic Timeout / session-timeout info), and keep other ERROR cases as job-level errors in both parallel and sequential branches.
Final Verdict

Status: ⚠️ Request changes
Minimum required actions:

  1. Narrow flaky-mode error suppression to explicit session-timeout cases only.
  2. Keep non-timeout pytest ERROR conditions as job-level errors.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 26, 2026
failed_tests_files.extend(test_result_parallel.files)
if test_result_parallel.is_error():
if not is_targeted_check:
if not is_targeted_check and not is_flaky_check:

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.

This condition now suppresses all Result.Status.ERROR outcomes in flaky mode, not only expected soft session-timeout cases.

If pytest exits with an internal/usage/unknown error (for example exitstatus 3/4/None), test_result_*.results can be empty; combined with the later Timeout filtering, the job can finish OK even though pytest failed.

Please keep has_error = True for non-timeout errors and only ignore explicit session-timeout cases (for example by checking test_result_*.info/the synthetic Timeout marker before suppressing). The same guard at line 976 needs the same treatment.

if is_flaky_check:
elapsed_for_flaky = int(sw.duration)
flaky_check_remaining_s = max(FLAKY_CHECK_TIME_LIMIT - elapsed_for_flaky, 0)
if flaky_check_remaining_s < 60:

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.

We may want to set it greater, to be at least the single test timeout or the single test maximum time, e.g., 180 sec, but better - 300 sec.

@alexey-milovidov alexey-milovidov self-assigned this May 26, 2026
@alexey-milovidov
alexey-milovidov merged commit a130368 into ClickHouse:master May 31, 2026
165 of 166 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 31, 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.

3 participants