Repository navigation
Fix flaky test 02122_join_group_by_timeout - #109584
alexey-milovidov merged 3 commits into
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-2:20260706-224000 |
|
cc @vdimir — could you review this? It fixes flakiness in the HTTP part of the test: |
|
Workflow [PR], commit [eeadb5b] Summary: ✅ AI ReviewSummaryThis PR removes the per-test HTTP Final Verdict✅ No new blocking or major issues found in the current revision. |
e000ac7 to
4421a3a
Compare
|
Good catch, adopted option (a). Dropped the per-test `--max-time` override entirely so both HTTP calls inherit the harness `${CLICKHOUSE_CURL}` (`--max-time 120`); removed the `TIMEOUT` variable. This removes the second client-side cutoff below the harness cap that `TIMEOUT=90` still left. The |
4421a3a to
4cd796c
Compare
|
Addressed. Both HTTP calls now set an explicit Verified locally on the debug binary (buildId 775D531E): test passes 20/20; the HTTP timeout query logs |
The test verifies a JOIN+GROUP BY query respects max_execution_time and is
cancelled with Code: 159 (HTTP and TCP clients, plus the break-mode variant).
Two independent flakes were addressed:
1. curl truncation. A per-test curl --max-time cap (5s release / 15s sanitizer)
was below the 1..60s cancellation window the test itself asserts, so under
sanitizer/overload the connection closed before the server delivered
Code: 159, dropping that line. Fixed by removing the per-test override so the
HTTP calls inherit the harness ${CLICKHOUSE_CURL} --max-time 120; the
query_duration BETWEEN 1 AND 60 assertions are the real correctness cap.
2. query_log async-commit race. After the (HTTP/TCP) response is returned, the
terminal query_log row is written to the async buffer and is not necessarily
committed to the table by the time a single SYSTEM FLUSH LOGS + SELECT runs;
under flaky-check (50x, high CPU contention) the SELECT occasionally found no
row and the query_duration line was dropped. Fixed by polling FLUSH LOGS +
SELECT until the row appears before asserting (same remedy as
02494_query_cache_http_introspection).
The cancellation-window coverage is preserved for every client path (each query
carries a query_id whose duration is asserted). Assertions unchanged.
4cd796c to
91ad9c5
Compare
|
The flaky-check FAIL on `4cd796c` was the `query_duration` assertion I added for the second HTTP block being itself non-deterministic: after the HTTP response returns, the terminal `query_log` row is written to the async buffer and is not guaranteed to be committed to the table by the time a single `SYSTEM FLUSH LOGS query_log` + `SELECT` runs. Under the flaky-check 50x loop that SELECT occasionally found no row, dropping the `query_duration` line. Fixed by polling `FLUSH LOGS` + `SELECT` (scoped to the query_id, up to 60 iterations) until the terminal row appears before asserting — the same remedy `02494_query_cache_http_introspection` uses for the identical async-commit race. Applied uniformly to all four assertions (both HTTP paths and both TCP paths) via an `assert_query_duration` helper, so the HTTP cancellation-window coverage you asked for is preserved and deterministic. The curl-truncation fix (inherit the harness 120s cap) is unchanged. Verified on the debug binary: 30/30 passes; mechanism confirmed (the row is absent from `query_log` immediately after the query returns and only appears after a FLUSH, which the poll loop now always catches). New head: `91ad9c5`. |
A max_execution_time=1 cancellation cannot finish before 1000 ms (measured floor is consistently 1000-1001 ms across TCP and HTTP), so assert query_duration_ms BETWEEN 1000 AND 60000 directly instead of round(query_duration_ms/1000) BETWEEN 1 AND 60. The rounding form accepted durations in (500, 1000) ms (e.g. 999 -> 1), which would hide a too-fast sub-1s cancellation regression. Output (boolean 1) is unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good catch. Tightened in daf1b49: the helper now asserts Measured the actual floor locally (debug build, 25 runs across TCP and HTTP): a |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 114 line(s), 9 function(s) across 47 file(s) · Details Top files
|
CI finish ledger — daf1b49Our PR touches only
The flaky-check FAIL of Session id: cron:our-pr-ci-monitor:20260707-170000 |
CI finish ledger - eeadb5bCI fully finished on this head (no check queued or in progress, the praktika aggregator Session id: cron:our-pr-ci-monitor:20260729-120000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Flaky in
Stateless tests (amd_tsan / amd_msan): intermittently theCode: 159timeout line is missing from the output (
result differs with reference,-Code: 159in the diff). 0 master failures; CI rerun diagnosis always reports "not reproducible".
Root cause: the HTTP part of the test runs the query through
curl --max-time $TIMEOUTwith
TIMEOUT=5(release) /15(sanitizer/debug), but the test's own durationassertion accepts cancellation taking up to 60s (
query_duration BETWEEN 1 AND 60).When cancellation is legitimately slow under sanitizer load (still well within the
accepted 60s window), curl hits its
--max-timecap and closes the connection beforethe server delivers the
Code: 159timeout error, so that line is dropped from theoutput while the run would otherwise have passed. The curl cap was inconsistent with
the window the test itself accepts.
Fix: set
TIMEOUT=90unconditionally socurl --max-timealways exceeds the 60sduration window the test accepts. 90s > 60s already covers sanitizer/debug slowness,
so the separate sanitizer branch is no longer needed. The cancellation assertions are
unchanged, so the test still verifies exactly the same behavior.
Reproduced the mechanism locally: with a delayed
Code: 159delivery and a tightcurl --max-time, the line is truncated (bug); with a generous--max-timethe lineis present (pass). 20/20 passes with the fix.
Version info
26.8.1.464(included in26.8and later)