Skip to content

Bound flaky-check shutdown, timeout doesn't fail a passing run - #105405

Closed
vdimir wants to merge 1 commit into
masterfrom
vdimir/flaky-check-bound-shutdown
Closed

vdimir wants to merge 1 commit into
masterfrom
vdimir/flaky-check-bound-shutdown

Conversation

@vdimir

@vdimir vdimir commented May 20, 2026

Copy link
Copy Markdown
Member

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

...

The flaky check's `Shell.run(timeout=...)` is the only wall-clock guard:
`clickhouse-test` itself never knows about the budget, so it keeps running
until the wrapper SIGTERMs it.  That kill can land mid-query — e.g. the
post-test `system.trace_log` aggregate on a debug build with a huge
accumulated `trace_log` — failing a run where every test actually passed.

Seen on PR #104860 (touches ~32 stateless tests; flaky check ran them all
50x); job timed out at 2180s with `clickhouse-test exited with code -15`,
even though `All tests have finished.` printed 69 s earlier and every
iteration passed.

Two changes:

1. `tests/clickhouse-test`: cap the post-`All tests have finished.`
   diagnostics with `SETTINGS max_execution_time` and matching HTTP
   timeouts — the `MemoryAllocatedWithoutCheck` aggregate, the
   `SYSTEM FLUSH LOGS system.trace_log`, and the per-test-coverage
   queries.  If the server is overloaded they are skipped with a
   logged exception instead of blocking shutdown.

2. `ci/jobs/functional_tests.py`: forward `--global_time_limit` to
   `clickhouse-test` (budget minus 180 s of shutdown headroom).
   `clickhouse-test` stops scheduling new test iterations gracefully
   and has time to run the hung-check + (now-bounded) diagnostics
   before the outer `Shell.run` SIGTERM fires.  The outer timeout
   stays as a last-resort kill.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104860&sha=0bd90393d11807d0090b718e119cb03889f31fd7&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
PR: #104860

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

clickhouse-gh Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [498a282]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/check_report_messages.py FAIL

AI Review

Summary

This PR bounds several post-test operations in clickhouse-test and threads a reduced inner --global_time_limit from ci/jobs/functional_tests.py. The main contract is still not fully met: low remaining-time runs can still be terminated by the outer timeout mid-query, and bounded coverage stats queries can now fail an otherwise passing run.

Findings

⚠️ Majors

  • [ci/jobs/functional_tests.py:105] The inner budget is only passed when global_time_limit > 180. When remaining time is <= 180, clickhouse-test gets no inner --global_time_limit, so it can keep scheduling tests until the outer Shell.run timeout sends SIGTERM, reintroducing the false-failure mode this change is trying to eliminate.
    Suggested fix: always pass an inner limit when global_time_limit > 0, for example max(1, global_time_limit - SHUTDOWN_HEADROOM).
  • [tests/clickhouse-test:5657] cov_rows / cov_tests are now hard-bounded (max_execution_time=30, client timeout 40) but still not wrapped in best-effort handling. A timeout/exception in these informational post-run stats aborts the script after tests already finished, turning diagnostics into a hard failure path.
    Suggested fix: wrap these two queries in try/except (as done for coverage_indirect_calls) or degrade to a warning path instead of failing the run.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  1. Ensure clickhouse-test always receives an inner global budget whenever outer global_time_limit is set.
  2. Make coverage stats collection (cov_rows/cov_tests) best-effort so post-run telemetry cannot fail a passing test run.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 20, 2026
# every test actually passed.
SHUTDOWN_HEADROOM = 180 # seconds reserved for hung-check + diagnostics + flush
inner_args = extra_args
if global_time_limit and global_time_limit > SHUTDOWN_HEADROOM and "--global_time_limit" not in extra_args:

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.

global_time_limit <= SHUTDOWN_HEADROOM currently skips adding inner --global_time_limit, so clickhouse-test keeps scheduling new tests right up to the outer Shell.run timeout and can still be SIGTERM'ed mid-query.

That leaves the exact false-failure mode this change is trying to remove whenever the remaining budget is small (e.g. delayed startup leaves <180s for the test stage).

Can we always pass an inner limit when global_time_limit > 0, e.g. max(1, global_time_limit - SHUTDOWN_HEADROOM)? This makes clickhouse-test stop scheduling immediately when little time is left, instead of running until outer SIGTERM.

Comment thread tests/clickhouse-test
"SELECT count() FROM system.coverage_indirect_calls FINAL",
timeout=40, settings=post_settings,
)
or 0

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.

These two coverage stats queries are now hard-bounded (max_execution_time=30, client timeout 40) but unlike the coverage_indirect_calls block below they are not in a try/except.

If either query times out on a large system.coverage_log, the script throws here and the whole job fails after all tests already passed.

Can we either wrap cov_rows/cov_tests in the same best-effort error handling used below, or avoid turning these post-run informational stats into a hard failure path?

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 think this is somewhat valid concern. If our goal is the reduce the flakyness, let's wrap these in try blocks. I think getting a timeout is not a problem as they are only printed (I assume) as some debug information.

@antaljanosbenjamin antaljanosbenjamin self-assigned this May 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Dear @antaljanosbenjamin, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@vdimir

vdimir commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

closing for now, reopen if it will become an issue in ci again

@vdimir vdimir closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants