Repository navigation
Fix a failed web terminal query staying in system.processes until the next query of the session - #127913
Conversation
`LocalConnection` released the query state (the `BlockIO` that owns the process list entry, and the `QueryScope` of the client thread) only in `finishQuery` (the `EndOfStream` path), in the next `sendQuery`, or when the connection was destroyed. A query that failed after `executeQuery` returned delivered its `Exception` packet and kept its state, so in the web terminal and the SSH interface it stayed in `system.processes` while the session was idle at the prompt: it counted toward `max_concurrent_queries_for_user`, and `KILL QUERY ... SYNC` on it did not return. In the Stress test a leaked web terminal session kept such a query listed for 45 minutes and failed the hung check. Reset the state when the `Exception` packet is handed to the client, as `finishQuery` does for `EndOfStream` and as `TCPHandler` does with its per-query state. `sendCancel` can now be reached with no query (the catch of `ClientBase::processInsertQuery`), so it ignores the cancel then, with the same guard as ClickHouse#127364. 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; 0 findings) plus my own cold review (1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261027-043400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261027-040000 |
|
cc @azat @yakov-olkhovskiy, could you review this and add the |
|
Workflow [PR], commit [99681c0] Summary: ❌
AI ReviewSummary
Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested. |
CI finish ledger - 99681c0Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The first run of this head stopped at Session id: cron:our-pr-ci-monitor:20261027-203012 |
d457836
Related: #127364
Related: #126995
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a failed query staying in
system.processeswhile the web terminal or SSH session that ran it was idle. Such a query counted towardmax_concurrent_queries_for_user, andKILL QUERY ... SYNCon it hung.Description
On 26.8.28.14, after
SELECT throwIf(number = 0) FROM numbers(1)fails in a web terminal session, the query stays insystem.processeswhile the session is idle at the prompt; from another clientSELECT 1 SETTINGS max_concurrent_queries_for_user = 1is rejected withTOO_MANY_SIMULTANEOUS_QUERIES, andKILL QUERY ... SYNCon it hangs.Provenance: Stress test (arm_asan_ubsan),
Hung check failed: a web terminal query that failed on an injected memory fault was listed for 45 minutes. That session itself leaked because of the PTY inheritance addressed by #126995 (open); this PR fixes the stale entry, which also affects any ordinary idle session.Root cause:
LocalConnectionreleased the query state (theBlockIOowning the process list entry) only infinishQuery(EndOfStream), in the nextsendQuery, or on destruction. A query that failed afterexecuteQueryreturned delivered itsExceptionpacket and kept its state.Change:
receivePacketresets the state when it hands out theExceptionpacket, asfinishQuerydoes forEndOfStreamand asTCPHandlerdoes with its per-query state.sendCancelcan then be reached with no query, so it gets the sameif (!state) return;guard as #127364 (identical hunk, so the two PRs merge in either order).Validation: the new test
05453_webterminal_query_error_leaves_processlistprints1on master and0with the fix (5/5 each); 50/50 randomized runs and 50 with-j 8pass; thewebterminal|sshand_localselections show no new failures against the unpatched build.Workflow [PR]
Sync PR [sync-upstream/pr/127913]
Version info
26.11.1.1794-master(included in26.11and later)