Repository navigation
Description
Issue
TPCH Q16 (supplier count query) hangs indefinitely on TPCH 100G dataset due to a deadlock in the Shuffle execution engine. The query has been running for 15+ hours (normally completes in ~3 seconds). The root cause is that Shuffle consumer goroutines are permanently blocked in ShufflePool.waitBatchOrEnd() because the producer pipeline exited without sending the end-of-data signal.
This causes the entire TPCH 100G benchmark to stall — Q1-Q15 complete normally, but Q16 never returns.
Environment
| Field | Value |
|---|---|
| CI Run | https://github.com/matrixorigin/mo-auto-test/actions/runs/29764528161/job/88440134273 |
| Branch | main |
| MO commit | 0102f7b85bcb8d960d7cc16a14b71682a58e7910 |
| Runner | mo-srv-129 (10.222.1.129, IDC self-hosted) |
| Topology | Single CN + Single TN (launch mode) |
| GOMEMLIMIT | 80000 MiB |
| Stuck step | Start TPCH 100G Test (started 2026-07-20 19:08:32 UTC, still running after 15+ hours) |
Stuck Query (TPCH Q16)
SELECT p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt
FROM partsupp, part
WHERE p_partkey = ps_partkey
AND p_brand <> 'Brand#35'
AND p_type not like 'ECONOMY BURNISHED%'
AND p_size in (14, 7, 21, 24, 35, 33, 2, 20)
AND ps_suppkey not in (
SELECT s_suppkey FROM supplier WHERE s_comment like '%Customer%Complaints%'
)
GROUP BY p_brand, p_type, p_size
ORDER BY supplier_cnt desc, p_brand, p_type, p_size- Query started: 2026-07-20 19:10:19 CST (confirmed via
mo_catalog.mo_sessions) - Running for: 912+ minutes (15.2+ hours) and still not completed
- Normal duration: 3.0-3.2 seconds per turn (baseline from 2026-07-18 run)
- Regression factor: ~10000x
Query Execution Plan
AP QUERY PLAN ON MULTICN(64 core)
Project
-> Sort (supplier_cnt DESC, p_brand, p_type, p_size)
-> Aggregate (count(distinct ps_suppkey))
-> Aggregate (Group: p_brand, p_type, p_size, ps_suppkey)
shuffle: range(partsupp.ps_suppkey)
-> ANTI JOIN (hashOnPK: partsupp.ps_suppkey = supplier.s_suppkey)
-> INNER JOIN (hashOnPK: partsupp.ps_partkey = part.p_partkey)
shuffle: range(partsupp.ps_partkey)
-> Table Scan on partsupp
-> Table Scan on part (filter: p_size, p_brand, p_type)
-> Table Scan on supplier (filter: s_comment like)
Root Cause: Shuffle Deadlock
Goroutine Analysis (live pprof from debug HTTP :6060)
Total goroutines: 2404
| Goroutine | State | Blocked Duration | Location |
|---|---|---|---|
| 85679 | chan receive |
435 min | Scope.MergeRun (scope.go:375) — parent scope waiting for child pipelines |
| 135584 | select |
433 min | shuffle.(*Shuffle).Call → group.(*Group).Call → connector.(*Connector).Call |
| 132044 | select |
433 min | shuffle.(*Shuffle).Call → group.(*Group).Call → connector.(*Connector).Call |
| 132039 | select |
433 min | ShufflePool.waitBatchOrEnd (shufflepool.go:396) |
| 135597 | select |
433 min | ShufflePool.waitBatchOrEnd (shufflepool.go:396) |
| 135578 | select |
433 min | ShufflePool.waitBatchOrEnd (shufflepool.go:396) |
| 135581 | select |
433 min | ShufflePool.waitBatchOrEnd (shufflepool.go:396) |
| 135582 | select |
433 min | ShufflePool.waitBatchOrEnd (shufflepool.go:396) |
Deadlock Chain
Producer pipeline (TableScan → Join → Filter)
→ Completes execution and goroutine exits
→ FAILS to send "end of data" signal to ShufflePool
→ Shuffle consumer goroutines stuck in waitBatchOrEnd() forever
→ Parent Scope.MergeRun() blocked on chan receive waiting for children
→ Query never returns
Key Evidence
-
No producer goroutines remain:
TableScan,HashBuild, andFiltergoroutines for this query are gone — they exited without signaling completion. -
CPU is idle: 5-second CPU profile shows only 34.2% utilization, all in runtime internals (
futex,syscall,selectgo). No query computation is happening. -
MySQL is responsive: The MO instance accepts new connections and runs other queries normally — only this specific Q16 session is deadlocked.
-
mo_catalog.mo_sessionsconfirms: Session019f80ef-ae51-7731-ba1a-7c49a40fdcfahas been running Q16 ontpch_100gdatabase since 19:10:19 CST.
Baseline Comparison (2026-07-18, same runner, same config)
| Metric | Normal (7/18) | Current (deadlocked) |
|---|---|---|
| Q16 per-turn cost | 3.0-3.2 seconds | >15 hours, not completed |
| Full 22-query turn | ~110 seconds | ❌ Stuck at Q16 in turn 1 |
| 5-turn total | ~9.5 minutes | ❌ |
| CPU during query | Normal | ~0% (all blocked in wait) |
| Slowest queries (normal) | Q15 ~15s, Q9 ~10s, Q17 ~9s | Q16 > 15 hours |
Suggested Investigation Areas
-
pkg/sql/colexec/shuffle/shufflepool.go:396—waitBatchOrEnd(): Add a timeout or context cancellation mechanism so consumers don't block forever if the producer dies. -
Producer pipeline exit path: Ensure all producer pipelines (especially
TableScan→Join→Filterchains) send the end-of-data signal to the ShufflePool in all exit paths, including error/early-exit paths. -
pkg/sql/colexec/shuffle/shuffle.go:136andshuffle.go:160: Review the shuffle Call logic for race conditions between producer completion and consumer waiting. -
Query timeout: Add a configurable query-level timeout so that deadlocked queries are eventually killed rather than running indefinitely.
How to Reproduce
- Build MO from commit
0102f7b8with launch mode (single CN + single TN) - Load TPCH 100G data
- Run
./run.sh -q all -s 100 -t 5(TPCH 100G, 5 turns) - Observe Q16 hanging indefinitely
Note: This may be non-deterministic — the deadlock depends on the timing of producer pipeline completion vs consumer goroutine scheduling.
Activity
fix: isolate fixed-bucket shuffle backpressure (#26017)
aunjgr commentedon Jul 22, 2026
fixed
Ariznawlll commentedon Jul 22, 2026
commit:2eb7f523e5a10f352d3e258183ed8440510388de
https://github.com/matrixorigin/mo-auto-test/actions/runs/29914894557/job/88907499740
还是会卡住,再看看 @aunjgr
Ariznawlll commentedon Jul 22, 2026
新证据:TPCH 孤儿查询在 server 端运行 10+ 小时
在
mo-auto-testbisect run 29914894557 中,通过直连mo-srv-129的 MO 实例发现:孤儿查询现场
上一个 nightly run 的 TPCH job 被 cancel 后,server 端 Q9 查询没有被 kill,在 MO 上持续运行了 10+ 小时。后续新的 bisect run 启动后,TPCH 100G 测试步骤卡住 2+ 小时。
MO server 状态
runtime.gopark(空闲等待)与本 issue 的关系
本 issue 描述的 TPCH Q16 hang 和这个孤儿查询问题有相同的底层缺陷:客户端断开/超时后,server 端查询不自动终止。
两者都需要 server 端具备查询生命周期管理——当客户端不再存在时,自动终止对应的 server-side 查询。
fix: prevent nested local shuffle deadlocks (#26055)
fix: decouple local shuffle producers from consumers (#26097)
aunjgr commentedon Jul 24, 2026
@Ariznawlll 还hung吗?麻烦验证一下
Ariznawlll commentedon Jul 24, 2026
https://github.com/matrixorigin/mo-auto-test/actions/runs/30029688851/job/89296735164
hung的问题已修复
fix: isolate fixed-bucket shuffle backpressure (matrixorigin#26017)
fix: prevent nested local shuffle deadlocks (matrixorigin#26055)
fix: decouple local shuffle producers from consumers (matrixorigin#26097
fix: isolate fixed-bucket shuffle backpressure (matrixorigin#26017)
fix: prevent nested local shuffle deadlocks (matrixorigin#26055)
fix: decouple local shuffle producers from consumers (matrixorigin#26097
fix: isolate fixed-bucket shuffle backpressure (matrixorigin#26017)
fix: prevent nested local shuffle deadlocks (matrixorigin#26055)
fix: decouple local shuffle producers from consumers (matrixorigin#26097