Repository navigation
Conversation
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-3:20260615-232600 |
|
cc @davenger @KochetovNicolai — could you review? This fixes a |
|
Workflow [PR], commit [962f687] Summary: ✅
AI ReviewSummaryThis PR makes PR Metadata
Final VerdictStatus: ✅ Approve No code-review changes are required. The metadata nit above is optional cleanup for template precision. |
c1563f3 to
f982c6c
Compare
… re-enqueue
The remote distributed-plan executor (DistributedQueryPlanExecutorRemote) tracks
worker tasks with a TaskTracker that polls their status on a thread pool. Each
status-check worker lambda, after running checkStatusFunc, re-enqueues the next
check via enqueueGetStatus() -> ThreadPool::scheduleOrThrow(). That tail ran
outside the lambda's try/catch.
scheduleOrThrow() can throw CANNOT_SCHEDULE_TASK during shutdown, and the lambda
can also hit MEMORY_LIMIT_EXCEEDED (e.g. under serverfuzz fault injection). Such
an exception escaped the worker lambda, was stored as the pool's first_exception,
and then rethrown by thread_pool.wait() in ~TaskTracker. An exception leaving a
destructor calls std::terminate, aborting the server (Received signal 6) during
pipeline teardown:
std::terminate
~TaskTracker -> thread_pool.wait()
~DistributedQueryPlanExecutorRemote
~ReadFromDistributedPlanSource
Fix:
- Route the re-enqueue through the same failure path as the status check: wrap
the lambda tail in try/catch and funnel both into a new recordFailure() helper
that stores first_exception and requests cancellation, so the query fails
cleanly via checkCancelled() instead of escaping the thread.
- Make ~TaskTracker exception-safe as a last line of defense: thread_pool.wait()
must still run (it joins worker threads while logger/lock/context are alive),
but a rethrown exception is now logged and swallowed instead of terminating.
A REGULAR failpoint distributed_plan_status_check_reenqueue_fault is added at the
re-enqueue site to make the crash reproducible on demand. The new stateless test
(04340) enables it and runs distributed queries; it then asserts the fault path
actually ran by checking system.text_log for the TaskTracker::recordFailure entry
(emitted on the pool thread on every re-enqueue), and verifies the server is still
alive. The recordFailure log is used rather than the client-visible error because
whether the query surfaces the stored exception to the client is racy, while the
log is deterministic, so the test does not become flaky under randomized settings.
The assertion is scoped to the current run by capturing a microsecond timestamp
before enabling the failpoint and filtering text_log on event_time_microseconds,
so a recordFailure row left by an earlier run on the same server (the flaky check
reruns the test in place) cannot make a later run pass without firing the failpoint.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
f982c6c to
7f4c024
Compare
|
@groeneai resolve the conflicts with master |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 25/27 (92.59%) | Lost baseline coverage: none · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server abort (
std::terminate, signal 6) during teardown of a distributed-plan query (make_distributed_plan = 1) when a worker status-check failed to re-schedule the next check (for exampleCANNOT_SCHEDULE_TASKon shutdown orMEMORY_LIMIT_EXCEEDED). The query now fails cleanly and the server keeps running.Description
Found by CI (Stress test, AST/BuzzHouse fuzzers) as a recurring
Received signal 6/std::terminatein~DistributedQueryPlanExecutorRemote. CI report:https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107565&sha=8696805ace5dc74831f1ee4ac4645fbe5d43d71d&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
Root cause: the remote executor's
TaskTrackerpolls worker task status on a threadpool. Each worker lambda, after
checkStatusFunc, re-enqueues the next check viaenqueueGetStatus() -> ThreadPool::scheduleOrThrow(). That tail ran outside the lambda'stry/catch.
scheduleOrThrow()can throwCANNOT_SCHEDULE_TASKduring shutdown, and thelambda can hit
MEMORY_LIMIT_EXCEEDEDunder fault injection. The exception escaped thelambda, was stored as the pool's
first_exception, and was rethrown bythread_pool.wait()in
~TaskTracker. An exception leaving a destructor callsstd::terminate, aborting theserver during pipeline teardown:
Fix (two layers):
is wrapped in try/catch and funnelled into a new
recordFailure()helper that storesfirst_exceptionand requests cancellation, so the query fails cleanly viacheckCancelled()instead of escaping the thread.~TaskTrackeris made exception-safe as a last line of defense:thread_pool.wait()still runs (it joins worker threads while logger/lock/context are alive), but a rethrown
exception is now logged and swallowed instead of terminating.
Reproduction and validation: a
REGULARfailpointdistributed_plan_status_check_reenqueue_faultis added at the re-enqueue site. Built bothways and verified locally with a single-node self-worker setup:
std::terminate->~TaskTracker->~DistributedQueryPlanExecutorRemotestack above.CANNOT_SCHEDULE_TASK)and the server stays alive.
New stateless test
04340_distributed_plan_status_reenqueue_faultenables the failpoint,runs distributed queries, and asserts the server is still serving queries afterwards.
No related open issue found (the broader multi-stage distributed family is tracked under
the re-land PR #107146).
Version info
26.6.1.892