Repository navigation
Fix query hang in local execution of distributed plans - #111762
Conversation
…d of blocking the pipeline thread Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [3ead130] AI ReviewSummaryThis PR tackles the local distributed-plan hang by turning in-memory exchange reads into timed polls, filtering synthetic zero-row chunks before they reach the client, and running fuzzed queries under their own thread group. The empty- Findings❌ Blockers
Tests
Final VerdictChanges requested: the deadlock fix is not complete for zero-column in-memory exchanges, and the regression evidence is still not deterministic. |
…bugprone-optional-value-conversion`) Co-Authored-By: Claude Fable 5 <[email protected]>
…change path as empty `Data` packets Co-Authored-By: Claude Fable 5 <[email protected]>
…er/fix-in-memory-exchange-deadlock
03394_distributed_shuffle_join_with_aggregation under runtime-filter randomization
#112026
…er/fix-in-memory-exchange-deadlock
| /// output makes the port full and lets other processors run. | ||
| auto chunk = exchange->getChunk(std::chrono::milliseconds(10)); | ||
| if (!chunk) | ||
| return Chunk(getPort().getHeader().cloneEmptyColumns(), 0); |
There was a problem hiding this comment.
Chunk(getPort().getHeader().cloneEmptyColumns(), 0) only creates a real "push" when the exchange header has at least one column. For a zero-column stream this becomes Chunk({}, 0), which is empty(), so ISource::work leaves has_input = false and the source goes straight back to Ready without ever filling the output port.
That matters here because zero-column exchange streams are already a supported case for SELECT count() (NativeCompressedSink/NativeCompressedSource special-case empty headers in src/Processors/Sinks/NativeCompressedSink.cpp and src/Processors/Sources/NativeCompressedSource.cpp). A local distributed-plan count() stage can therefore still monopolize the only pipeline thread and hang in the same way this PR is trying to fix.
This needs a wake-up marker that also works for header-less streams, or an actually async source, before the deadlock is fully fixed.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
| -- With distributed_plan_execute_locally = 1 the initiator pipeline reads the result from an | ||
| -- in-memory exchange. If that reader blocked the pipeline thread instead of yielding, the source | ||
| -- that starts the producing tasks could never run and the query hung. Whether that happens depends | ||
| -- on processor scheduling order, so the queries are repeated several times. |
There was a problem hiding this comment.
Bugfix validation is showing that this still is not a real reproducer for the old deadlock: both per-arch functional validation jobs mark 04628_distributed_plan_local_execution_merge_no_deadlock as xfail, and the Finish Workflow summary says no architecture produced the expected "fails on master, passes on the PR" result.
Repeating the query a few times is still probabilistic, so we do not actually have regression evidence for the behavior the PR claims to fix. Please make the bad schedule deterministic here, or move the coverage into a lower-level executor test that can force the reader/driver ordering.
|
📊 Cloud Performance Report ✅ AI verdict: This PR changes in-memory exchange scheduling for distributed local plan execution (distributed_plan_execute_locally), adds a zero-row-chunk filter, and pins a thread group for AST-fuzzer queries — none of which is exercised by a standard single-node ClickBench SELECT. The only flagged query, clickbench Q15, shows a -11.2% wall-time improvement but essentially identical CPU time (2633 vs 2631 ms), so there is no work-backed cause; the deterministic gates correctly suppressed it as within master's variance band. No real per-query regression or improvement is attributable to this change. clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
… under the time limit Co-Authored-By: Claude Fable 5 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 83/83 (100.00%) · Uncovered code |
Pulls in the merged fix from #111762 (`Fix query hang in local execution of distributed plans`), which closed the flaky-test issue #112301 for `04367_distributed_plan_merge_scatter_multishard` - the only red check on this branch. The merge is clean and additive: none of this test-only PR's own files changed.
With
distributed_plan_execute_locally = 1the initiator pipeline contains a source that reads the result from an in-memory exchange, next to the source that starts the producing tasks. The exchange reader blocked the pipeline thread indefinitely waiting for a chunk. When the pipeline executor scheduled the reader before the source that starts the producers (withmax_threads = 1, or more generally when such readers occupy all pipeline threads), the producers never started and the query hung forever. Queries over aMergetable ofDistributedtables hit this regularly because one pipeline holds several driver/reader pairs, e.g.04367_distributed_plan_merge_scatter_multishardhangs this way withmax_threads = 1.The reader now waits with a short timeout and, when no data arrived yet, pushes a chunk with no rows instead of blocking. Pushing (rather than just yielding) matters: a source that returns no output stays ready and is rescheduled immediately, monopolizing the thread, while pushed output makes the port full and lets the executor run other processors. The end-of-data protocol of the exchange is unchanged.
The new test hangs on the code without the fix in 4 out of 4 runs and passes in about a second (debug build) with it.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a query hang in local execution of distributed query plans (
distributed_plan_execute_locally = 1): the in-memory exchange reader could block the only pipeline thread before the sources producing its data were started.🤖 Generated with Claude Code
Version info
26.8.1.566(included in26.8and later)