Skip to content

CI: bound the queries to the CI Logs cluster in the log-export setup by wall clock - #126217

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:ci-bound-ci-logs-cluster-queries
Oct 16, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:ci-bound-ci-logs-cluster-queries

Conversation

@groeneai

@groeneai groeneai commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #110173

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

...

Description

On 2026-10-16 between 01:40 and 02:21 UTC, 39 Performance Comparison jobs on master and nine PRs ended error with Job timed out ... timeout [7200], e.g. arm 1/6 on #125985 and amd 4/6 on master. The hour was lost before the first perf query: the CI Logs cluster probe in setup_log_cluster.sh blocked for up to 3646 s despite --connect_timeout 3 --receive_timeout=45.

receive_timeout does not bound a query. When it fires, the client cancels the query and then waits for the server to acknowledge the cancel with no time limit. The overloaded cluster (Too many simultaneous queries ... Current: 1033, maximum: 1000) does not read the cancel while the query is queued, so the probe ended only when the server answered (Code: 202 after 122-1067 s) or the remote end dropped the connection (ATTEMPT_TO_READ_AFTER_EOF at 45 + 3600 s).

Change: a remote_client helper runs clickhouse-client under timeout --kill-after 10 90, for both queries to the cluster: the probe and the per-table CREATE TABLE IF NOT EXISTS. A timed-out CREATE stops the table loop instead of costing another 90 s per table. The password goes through CLICKHOUSE_PASSWORD instead of the command line of timeout. 90 s is twice the client's receive_timeout and the bound the Python port of this probe in #116031 uses; a healthy probe takes about 2 s. The export stays best-effort and the callers treat the exit code as before.

Validation, locally, with a server that holds the probe in its query queue: before the change the probe took 120 s and 240 s for a 120 s and a 240 s queue wait, after it 90 s. A hung CREATE costs 90 s once, and the healthy setup and teardown create and drop the same tables as before.


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

Version info

  • Merged into: 26.11.1.104-master (included in 26.11 and later)

groeneai and others added 2 commits October 16, 2026 05:10
…by wall clock

The CI Logs cluster probe in `setup_log_cluster.sh` passes `--connect_timeout 3
--receive_timeout=45` and is meant to fail fast, but it blocked Performance
Comparison jobs for up to 3646 s on 2026-10-16 (39 jobs on master and nine PRs
timed out at 7200 s). When `receive_timeout` fires, the client cancels the
query and then waits for the server to acknowledge the cancel with no limit
(`ClientBase::receiveResult` checks the timeout only while not cancelled). An
overloaded cluster keeps the query in its `max_concurrent_queries` queue
without reading the socket, so the probe ended only when the server answered
(`TOO_MANY_SIMULTANEOUS_QUERIES` after 122-1067 s) or the remote end dropped
the connection (`ATTEMPT_TO_READ_AFTER_EOF` at 45 + 3600 s). The per-table
remote `CREATE TABLE IF NOT EXISTS` has the same unbounded wait.

Run both queries to the cluster through a `remote_client` helper that wraps
`clickhouse-client` in `timeout --kill-after 10 90`. A timed-out `CREATE`
stops the table loop, since the next table would wait another 90 s. 90 s is
twice the client's own `receive_timeout` (so a fast server-side error still
wins) and matches the Python port of this probe in ClickHouse#116031. The export stays
best-effort; callers only check whether the script succeeded.

Validated locally with a server that holds the probe in its query queue: the
unchanged script blocks 120 s / 240 s for a 120 s / 240 s queue wait, the new
one stops at 90 s; a hung `CREATE` now costs 90 s once; the healthy setup and
teardown, the transient-error retry and the credential masking are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pass the CI Logs password to the client through `CLICKHOUSE_PASSWORD`, so that it
is not in the command line of `timeout`, which does not wipe it like the client
does. Detect the expiry of `timeout` by the elapsed time, since the client's exit
code can have the same low byte.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (rounds r0 on d59e8a0, r1 on 2c482fa): 2 issues fixed, 2 nits noted
Finding Verdict
❌ The timeout wrapper kept the CI Logs password in its own command line for the whole query (the client wipes only its own argv) AGREE, fixed in r1: the password goes through CLICKHOUSE_PASSWORD
⚠️ Exit codes 124/137 can also be client error codes (low byte), so a client error could stop the table loop AGREE, fixed in r1: expiry is detected by the elapsed time
💡 A CREATE that the client abandons by itself after 45-90 s still continues to the next table Noted: no measured CI case in that window (0.1 s or at least 122 s), every measured slow case hits the 90 s bound
💡 $SECONDS has 1 s granularity, so a client error ending at 89.x s can be reported as a timeout Noted: a real expiry is never missed; the worst case is one best-effort table not exported from a cluster that already took about 90 s

Re-review of r1: no new findings.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Local server with max_concurrent_queries = 1, one query holding the slot, probe user's queue_max_wait_ms = 120000 / 240000: the unchanged script blocks 120.1 s / 240.1 s with the CI signature (Code: 202 + Waited for 45 seconds).
b Root cause explained? After receive_timeout the client cancels and waits for the cancel acknowledgement with no limit (ClientBase::receiveResult); a server holding the query in its queue does not read the cancel.
c Fix matches root cause? Yes. The script, which owns the "best-effort, must not slow the job" contract, bounds every query to the cluster by wall clock through one helper; client cancel semantics are left to the client owner.
d Test intent preserved / new tests added? CI script change, so no test of the test infrastructure. Validated locally (rows a, e).
e Both directions demonstrated? Probe 240.1 s before, 90.0 s after (rc 124); hung CREATE blocked past 200 s before, 90.6 s with one attempt after; password in timeout's command line before, not after; a fast exit-137 client error stopped the loop before, not after.
f Fix is general across code paths? Both queries to the cluster (probe, CREATE) go through the helper; the stop path is already timeout-bounded.
g Fix generalizes across inputs (params/datatypes/wrappers)? Healthy setup/teardown output unchanged, transient retry and no-credentials path unchanged, wrong password fails with Code: 516, no password in any output or command line.
h Backward compatible? (maintainer-approved exception only) Yes. Only a cluster that does not answer within 90 s is treated differently; callers check only success or failure.
i Invariants and contracts preserved? No setup query to the cluster lasts more than 100 s; timeout is detected by elapsed time, not exit code; a timed-out table gets no _sender/_watcher, so teardown is unchanged.

Session id: cron:clickhouse-impl-slot-6:20261016-053300

@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2c482fa]

Summary: ✅


AI Review

Summary

The PR bounds both CI Logs cluster setup queries with a 90-second wall-clock timeout and a 10-second kill grace, passes credentials through the environment, and stops further table exports after a timed-out CREATE TABLE. Review of head 2c482fa2c148e9f45b4b59d5dc58ddb4923dd5a4 found no actionable issues. Eight throwaway harness scenarios passed, covering healthy setup, timeout termination, forced termination, colliding client exit codes, transient retry, and credential handling.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this and add can be tested (CI did not start without it)? After receive_timeout the client waits for the cancel acknowledgement with no limit, so the CI Logs cluster probe in setup_log_cluster.sh blocked Performance Comparison jobs for up to an hour; this bounds both cluster queries with timeout 90.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 16, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 16, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 16, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 16, 2026
@groeneai groeneai mentioned this pull request Oct 16, 2026
Merged via the queue into ClickHouse:master with commit 973247c Oct 16, 2026
352 of 353 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 Oct 16, 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 comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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