Repository navigation
Report the task failure that stopped a distributed plan, not the closed exchange it caused - #118390
Conversation
Internal second-model reviewReviewed with a second model before publishing; one round of fixes applied.
💡 Two gtest arms added for the states nothing reached: a worker's null cancellation, and a bare Unchanged by choice: |
|
Workflow [PR], commit [46caa0f] Summary: ✅
AI ReviewSummaryThis PR reworks distributed-plan failure reporting so a query reports the task failure that stopped it instead of a follow-on exchange disconnect, and it adds new coverage around cancellation and root-cause propagation. The general direction looks right, but the current head still breaks mixed-version initiator/worker combinations in two separate wire paths, and one of the new tests does not actually force both delayed-failure scenarios it claims to cover. Findings❌ Blockers
Tests
Final Verdict❌ Request changes. The error-reporting logic is heading in the right direction, but the current wire changes are not rolling-upgrade safe, and the new root-cause test does not fully prove the delayed-report path it is meant to cover. LLVM Coverage ReportMeasured on commit 46caa0f.
Changed lines: Changed C/C++ lines covered: 429/466 (92.06%) · Uncovered code |
|
cc @davenger, could you review this? It follows up your #112590: on a |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes17 object files changed (+53.54 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units259 translation units recompiled, 2290 s compile time in total, 259 of them have a recent master baseline. |
CI finish ledger - 32f0600Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task CI is fully finished on this head: 147 pass / 26 skipping / 0 failing test rows in the CI
The one red from the previous head
Session id: cron:our-pr-ci-monitor:20260906-140126 |
| /// Version 2 added per-stream streaming-exchange ports to exchange_stream_sources. | ||
| static constexpr auto DBMS_DISTRIBUTED_TASK_SERIALIZATION_VERSION = 2; | ||
| /// Version 3 added the error code of a failed task to its status reply. | ||
| static constexpr auto DBMS_DISTRIBUTED_TASK_SERIALIZATION_VERSION = 3; |
There was a problem hiding this comment.
This is the task start format version, not the get_status format version. After this bump, serializeTask sends 3 for every remote fragment, DistributedQueryPlanExecutorRemote::startStage no longer lowers it, and deserializeTask rejects any version above its local DBMS_DISTRIBUTED_TASK_SERIALIZATION_VERSION. That means a newer initiator can no longer dispatch make_distributed_plan fragments to workers that still only understand task version 2, even though the task body itself did not change. Meanwhile the added error_code still is not gated on this value because it travels in DistributedQueryTaskStatus. Please keep DBMS_DISTRIBUTED_TASK_SERIALIZATION_VERSION at 2 unless the task payload changes, and version the status reply separately (for example via client_version on get_status).
There was a problem hiding this comment.
Confirmed, and the release side makes it concrete: DBMS_DISTRIBUTED_TASK_SERIALIZATION_VERSION is 2 in v26.8.1.2041-lts, v26.8.2.7-lts and branches 26.6, 26.7 and 26.8. serializeTask writes task_description.serialization_version as the first field (StatelessWorkerEndpoint.cpp:42), that member has exactly one initializer and no assignment left anywhere in src (DistributedPlanExecutor.h:220), and deserializeTask throws NOT_IMPLEMENTED above the local constant (StatelessWorkerEndpoint.cpp:108). So every fragment now goes out as 3, and a released worker refuses the start.
I also have to retract the remedy I suggested on the other thread. client_version cannot gate this field. The case that needs a gate is a new initiator reading an old worker's status reply, so the writer is the old worker, and at v26.8.1.2041-lts DistributedQueryTaskStatus has no error_code member and its write emits three fields. That worker does honour client_version (StatelessWorkerEndpoint.cpp:222-224,276 there), but it has nothing to gate on it. A client-declared version can only make a new worker suppress the field for an old initiator.
That direction needs no gate anyway: the released getTaskStatus calls in->eof() and discards the result (StatelessWorkerClient.cpp:129-130), so an old initiator ignores a trailing field from a new worker.
That leaves the reader tolerating absence rather than either side declaring a version, for example if (!in.eof()) readIntBinary(error_code, in); in read, with the constant back at 2. I have not checked whether eof() is a reliable end-of-body signal on that buffer under its max_tries = 3 retry path, so that is worth confirming before taking it. Your call.
|
📊 Cloud Performance Report ✅ AI verdict: This PR is scoped entirely to distributed-plan execution: cancellation/failure ranking, exchange peer-disconnect error codes, and task serialization version. None of that code runs in a standard single-server ClickBench query. The three flagged queries (Q28 +5.0%, Q33 +5.6%, Q34 +7.2%) all show essentially flat CPU time and either test disagreement or a median inside master's existing variance band, so they are run-to-run noise rather than a PR effect and were downgraded to not_sure. The Q34 envelope suppression looks correct: its median falls within the current-era band and the diff cannot touch its path. No real performance regression is attributable to this change. clickbenchFlagged queries (3 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
| SELECT x, count() FROM t_root_cause WHERE NOT throwIf(x = 777, 'reading task fails') GROUP BY x FORMAT Null; -- { serverError FUNCTION_THROW_IF_VALUE_IS_NON_ZERO } | ||
|
|
||
| -- The worker reports the failing task late, so every follow-on failure reaches the initiator first. | ||
| SYSTEM ENABLE FAILPOINT distributed_plan_delay_root_cause_report; |
There was a problem hiding this comment.
This only forces the delayed-root-cause ordering for one of these two queries. distributed_plan_delay_root_cause_report is registered as ONCE, so the first failing task after SYSTEM ENABLE FAILPOINT consumes it and the second query then runs without the forced delay. That leaves either the main task fails or the reading task fails case unproven under the exact ordering this PR is trying to pin down.
Please re-enable the failpoint before each delayed query (or split the cases / make the failpoint regular inside this no-parallel test) so both scenarios are actually exercised.
|
@groeneai @davenger — title/description suggestions: Description (currently
Ignore if intentional. |
…n_cancel 04335_distributed_plan_cancel fails with `Reason: having stderror:` on runs whose output is correct. Since ClickHouse#118390 merged (2026-09-09 05:40 UTC), public CI has 24 such runs out of 766 llvm_coverage runs of this test (3.1%), 0 of 1708 non-coverage runs, 3 of them on master; the first is 19 minutes after that merge. They are green only because a flaky-labelled failure is force-greened on coverage lanes; any other lane reds. ClickHouse#118390 added the test's two remote arms (distributed_plan_execute_locally = 0), so DistributedQueryPlanExecutorRemote::TaskTracker::cancel() is reachable from a stateless test for the first time. Its teardown waits a bounded 3 s per cancelled task (waitForTaskTerminal, 10 polls x 300 ms) for the task to leave "Running". On an instrumented build that overruns, and the initiator reports at Warning that it left the task for the worker to reclaim. clickhouse-test runs every client with --send_logs_level=warning, so the line is streamed to the stderr of whichever client's log queue the teardown thread is attached to, and the runner fails any test whose stderr is not empty. Fix the test rather than the severity. The warning is legitimate: the nullopt branch skips tryForgetTask, and for a task that has started, worker-side forgetTask is the only eraser of the worker's `tasks` map (cancelTask only sets a flag, shutdown() cancels and waits without erasing, and there is no TTL or reaper), so the branch really does leave that task's TaskState in place until restart. Demoting the line would remove the only report of it. Use `error` rather than `none` or `fatal`: it is the minimal suppression that fixes the measured failure, and it keeps the Error-level reports on this same teardown path streaming to the clients whose stderr the runner reads, which `none` and `fatal` would have discarded. Measured against one server, a failing query still delivers an <Error> line to the client at `error` and delivers none at `none`. Scope the level to the whole file rather than to the KILL client alone, because the line is not tied to one client. Forcing the branch, system.text_log attributes 7 lines to the `KILL QUERY ... SYNC` client, whose stderr is not redirected and which therefore reds the test, and 3 to the cancelled SELECT itself, whose stderr the test redirects into its own client log. Both happened within one run, so which client owns the teardown is a race. Not addressed here: the abandoned worker-side task entry that the warning reports. That is a separate question about the teardown's wait budget, not about this test's stderr. Related: ClickHouse#118390 Co-Authored-By: Claude Opus 5 <[email protected]>
Related: #112590
Changelog category (leave one):
Changelog entry
A failing
make_distributed_plan = 1query reports the error of the task that failed, not the closed exchange connection that failure caused. Worker task failures reach the client with the worker's error code.Description
One failing task makes every task connected to it fail too: their exchange sockets close, and the initiator's result reader sees the
maintask's socket close. The initiator kept the first failure it saw, and these follow-on failures usually arrive first. On master a failingmaintask under a remote streaming plan reportsPOCO_EXCEPTION"peer closed connection" in every run.DistributedQueryCancellationrecords every failure and ranks it: a consequence (QUERY_WAS_CANCELLED, the newEXCHANGE_PEER_DISCONNECTED) yields to an unclassified failure (RECEIVED_ERROR_FROM_REMOTE_IO_SERVER), which yields to a root cause; among equals the first stays. AfterKILL QUERYonly a root cause is recorded.EXCHANGE_PEER_DISCONNECTED.what(), which for a Poco exception is only its name.The teardown waits about 3 s per task for a cancelled task's terminal status. A root cause that arrives later is logged at warning level, but the query has been reported already.
Workflow [PR]
Sync PR [sync-upstream/pr/118390]
Version info
26.9.1.1015(included in26.9and later)