Repository navigation
Do not time out the async INSERT ... SELECT race tests when the insert ends between two polls - #122659
Conversation
…ert ends between two polls `wait_for_query_to_start` polls `system.processes` until the query id appears, so it cannot tell a query that has not started from one that has already finished. `04633_async_insert_select_alter_race` failed that way in `Stateless tests (amd_debug, parallel)` on PR ClickHouse#121687: the first poll took its `system.processes` snapshot 40 ms before the `INSERT` registered and then waited 2.96 s on the global mutex of `DateLUT` (both queries had a random `session_timezone`, and the last query of `01252_weird_time_zone` was building a `DateLUTImpl` for every zone under that mutex). The `INSERT` ran for 2.9 s inside that gap, every later poll found nothing, and the test exited after its 30 s budget with "Timeout waiting for query insert_case3_... to start". The helper now takes an optional third argument, the PID of the client that runs the query: when a poll finds nothing and that client has exited, the query has already run, so the helper returns. The PID check comes before the deadline check, so an exited client wins even after a stalled poll. The 7 barriers whose query is a short background `INSERT` (`alter_race` x4, `freeze_race` x2, `late_bound_catalog` x1) pass `$INSERT_PID`. Their output does not depend on whether the DDL lands during or after the `INSERT`, and a failed `INSERT` still fails the test through its stderr and the row counts. Callers with two arguments behave as before, including the `KILL QUERY` barrier in `04633_async_insert_select_accounting`, which needs its query alive. Verified with a `curl` wrapper that delays the first poll of each query by 15 s: master fails 9/9 with the CI message, this change passes 9/9, and each half alone still fails 9/9. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121687&sha=4686a70cd062c1eb96129f43bc5acc467f1b1539&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/36367474392/job/108763115465 PR: ClickHouse#121687 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20260928-100900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260928-090300 |
|
Workflow [PR], commit [42b42f8] Summary: ✅ AI ReviewSummaryThis PR removes a real flaky timeout in the async PR Metadata
Findings
Final VerdictChanges need follow-up before merge: the timeout fix also makes the affected race tests able to pass without observing any in-flight query, which weakens the regression coverage they are supposed to provide. |
The purpose is to WAIT for the query start. The function is called |
16b5ba7
Picks up ClickHouse#122659, which fixes the 04633_async_insert_select_late_bound_catalog wait timeout that failed this PR's last CI run. No conflicts; the PR's own change (FunctionToSubcolumnsPass.cpp and the 04692 test) is unchanged.
Related: #111663
Related: #121687
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04633_async_insert_select_alter_racefailed inStateless tests (amd_debug, parallel)on #121687 (an Iceberg change) withTimeout waiting for query insert_case3_... to start(job).Root cause.
wait_for_query_to_startpollssystem.processesuntil the query id appears, so it cannot tell "not started yet" from "already finished". In that run the first poll took its snapshot 40 ms before theINSERTregistered, then stalled for 2.96 s. TheINSERT(2.9 s) started and finished inside that gap, every later poll found nothing, and the 30 s budget ran out. The stall came from01252_weird_time_zone's last query: on its first run after server start it builds aDateLUTImplfor every zone underDateLUT's global mutex, and any query with asession_timezonewaits behind it (both queries had a random one).Fix.
wait_for_query_to_starttakes an optional third argument, the PID of the client that runs the query. When a poll finds nothing and that client has exited, the query has already run, so the helper returns. Fixing only the stall would leave the barrier lossy against any other delayed poll. The 7 barriers in04633_async_insert_select_{alter_race,freeze_race,late_bound_catalog}whose query is a short backgroundINSERTpass$INSERT_PID: one helper change instead of 7 local ones. Their output does not depend on whether the DDL lands during or after theINSERT, and a failedINSERTstill fails the test. Two-argument callers are unchanged, including theKILL QUERYbarrier in04633_async_insert_select_accounting, which needs its query alive.Validation. A
curlwrapper that delays the first poll of each query by 15 s reproduces the failure: master fails 9/9 with the CI message, this change passes 9/9, and each half alone still fails 9/9. 50/50 randomized runs of each changed test pass, and the whole04633_async_insert_selectfamily plus the 15 other tests with await_for_query_to_startbarrier pass both before and after.Workflow [PR]
Sync PR [sync-upstream/pr/122659]
Version info
26.10.1.921-master(included in26.10and later)