Repository navigation
Do not throw a logical error from the Pretty writing thread after the query has finished - #125028
Conversation
… query has finished
When the background writer of squashed Pretty blocks fails to write (for
example, the reader of the output pipe has exited), it stores the error and
then cancels the query through its process list element. In
`clickhouse-local` the output format is owned by the client and outlives the
query: if the main thread notices the stored error first while polling
(`checkBackgroundError`), it cancels, drains and finishes the query, which
destroys the process list entry, and only then destroys the format and joins
the writer. The writer then called the strict `getProcessListElement`, which
throws `LOGICAL_ERROR` ("Weak pointer to process_list_elem expired") for an
expired element, aborting debug and sanitizer builds (exit code 134 in
`05238_pretty_squash_broken_pipe`).
Use `getProcessListElementSafe`: an expired element means the query has
already finished, so there is nothing left to cancel, and the stored error
still reaches the client through the main thread.
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-8:20261010-021900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261010-015700 |
|
Workflow [PR], commit [b6242e5] Summary: ✅
AI ReviewSummaryThis PR replaces the strict Final Verdict
|
Related: #117005
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
05238_pretty_squash_broken_pipe(added by #117005) fails inStateless tests (amd_debug, parallel)withUnexpected exit code 134: #125004, #112650. Theclickhouse-localcore dump of the first job aborts inContext::getProcessListElement(LOGICAL_ERROR"Weak pointer to process_list_elem expired"), called fromPrettyBlockOutputFormat::writingThread.In
clickhouse-localthe output format outlives the query. When the main thread notices the background write error while it polls, it cancels and finishes the query, which destroys its process list entry, and only then destroys the format and joins the writing thread. If that thread has not reached its cancel call yet, the strict getter throws. The thread now usesgetProcessListElementSafe: an expired element means the query has already finished, and the stored write error still reaches the user (exit code 75).Not for changelog: #117005 is not in a release.
Validation (debug build) with a temporary 3 s sleep before the cancel call, on the test's
SELECT DISTINCTquery: master aborts 10/10, this PR exits 75 10/10 (also 10/10 on the first subtest's query). Without the sleep:05238_pretty_squash_broken_pipeand05061_pretty_squash_flush50/50 each with randomized settings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125028]
Version info
26.10.1.2035-master(included in26.10and later)