Repository navigation
Fix deadlock in non-memory-efficient merge of two-level aggregation blocks - #123352
Conversation
…locks `Aggregator::mergeBlocks` (used by `MergingAggregatedTransform`, e.g. for distributed queries with `distributed_aggregation_memory_efficient = 0`) ran its per-bucket merges as `max_threads` jobs on the aggregator's `thread_pool`. Merging two large two-level `uniqExact` states inside these jobs (`UniqExactSet::merge` with a thread pool) schedules nested jobs on the same pool and waits for them. The pool's queue size equals `max_threads`, and running jobs count against it, so when all outer jobs reached such a merge at once, the nested jobs could never be scheduled: the query hung forever and could not be cancelled. The per-bucket merges now run on a separate pool. Related: #117153 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [d720baf] Summary: ✅
AI ReviewSummaryThis PR breaks the deadlock between Final Verdict
LLVM Coverage ReportMeasured on commit d720baf.
Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 79 s compile time in total, 7 of them have a recent master baseline. |
Aggregator::mergeBlocks(used byMergingAggregatedTransform, e.g. for distributed queries withdistributed_aggregation_memory_efficient = 0) ran its per-bucket merges asmax_threadsjobs on the aggregator'sthread_pool. Merging two large two-leveluniqExactstates inside these jobs (UniqExactSet::mergewith a thread pool) schedules nested jobs on the same pool and waits for them. The pool's queue size equalsmax_threads, and running jobs count against it, so when all outer jobs reached such a merge at the same time, the nested jobs could never be scheduled: the query hung forever and could not be cancelled (allAggregatorPoolthreads waiting inThreadPoolCallbackRunnerLocal::enqueueAndGiveOwnership,TCPHandlerwaiting inPullingAsyncPipelineExecutor::cancel).The per-bucket merges now run on a separate pool, so
thread_poolstays available for the nested jobs (which do not nest further).The added test hangs on master every time and passes with the fix.
The issue was found while working on the parallel merge of keyed
uniqExactstates, which makes the nested scheduling much more frequent; that PR includes the same fix.Related: #117153
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a possible hang of a distributed
GROUP BYquery withuniqExactanddistributed_aggregation_memory_efficient = 0when merging large states of two-level aggregation.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123352]
Version info
26.10.1.1320-master(included in26.10and later)