Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Related but distinct: #32612 reports missing rows from multi-member recursive CTEs; #32795 / #32601 / #32600 report service crashes (stack overflow / process exit) from invalid recursive CTE shapes. This report is a third failure mode on the same multi-member machinery: a fully valid, anchored, terminating recursive CTE that never returns — the query hangs indefinitely with no error, no result, and no cte_max_recursion_depth cap firing. Reproduction below runs for 65+ seconds (client killed at 65s; server stays alive) where MySQL returns in milliseconds.
Branch Name
main
Commit ID
a626dd0 (binary 8.0.30-MatrixOne-v1.3.0)
Other Environment Information
- Hardware parameters: Apple Silicon (arm64, MacBook)
- OS type: macOS (darwin)
- Others: standalone single-process launch (
mo-service -launch). MySQL 8.0.45 reference on the same host returns instantly.SELECT git_version()reportsunknown; the server banner is8.0.30-MatrixOne-v1.3.0, built from main@a626dd045a (2026-11-13).
Actual Behavior
A 4-member recursive CTE whose final member references prior generations via s IN (0,1) (i.e. consumes rows produced before the immediately preceding round) hangs forever:
WITH RECURSIVE r(s,v) AS (
SELECT 0, 1
UNION ALL
SELECT 1, v*2 FROM r WHERE s = 0
UNION ALL
SELECT 2, v+10 FROM r WHERE s = 1
UNION ALL
SELECT 3, v-5 FROM r WHERE s IN (0, 1)
)
SELECT s, v FROM r ORDER BY s, v;-- MySQL 8.0.45 (milliseconds):
0 1
1 2
2 12
3 -4
3 -3
-- MatrixOne: no output, no error, no timeout message; client killed after 65s (timeout exit 124).
-- Server survives: SELECT 1 succeeds afterwards.
The hang is reproducible 3/3 and is not a slow-plan issue — the row set is tiny (5 rows) and semantically terminates after one consume round.
Expected Behavior
Return all 5 rows as MySQL does (shown above). If an engine limit is hit, cte_max_recursion_depth should terminate the query with an error rather than executing unboundedly.
Steps to Reproduce
Run the single statement above (no tables or fixtures needed — pure literal recursion).
Bisected trigger matrix (all against the same instance, 20-25s杀手 client timeouts):
| # | Recursive member shape | Result |
|---|---|---|
| 1 | 3 members, last consumes only prior round (WHERE s = 1) |
✅ completes (but loses rows — the #32612 family) |
| 2 | 3 members, last consumes two generations (WHERE s IN (0,1)) |
🔴 hangs |
| 3 | 4 members, member 3 consumes two gens (IN (0,1)), member 4 consumes one (= 2) |
🔴 hangs |
| 4 | 4 members, every member consumes only its immediately prior round (= 0, = 1, = 2) |
✅ completes (drops rows, #32612 family) |
| 5 | 4 members, member 4 consumes three gens (IN (0,1,2)) |
🔴 hangs |
Trigger condition (bisected): any recursive member that consumes rows from more than one prior generation (WHERE s IN (list-with->1-element) spanning earlier rounds) — i.e. not the immediately preceding frontier — sends the recursive executor into an infinite loop. Members restricted to a single prior generation merely lose rows (#32612); cross-generation consumption hangs.
Additional information
- This is likely a scheduling bug in the same machinery [Bug]: Recursive CTE with multiple recursive members omits later-generation rows #32612 analyzed:
pkg/sql/colexec/dependent/recursive.go:135-179(frontier selection and next-round reset at:157/:179) andpkg/sql/colexec/mergecte/mergecte.go:111-166. [Bug]: Recursive CTE with multiple recursive members omits later-generation rows #32612's missing-row symptom suggests the next-round reset drops rows; here the cross-generation predicate presumably keeps the frontier non-empty forever, so the loop never observes a terminating (empty) round. - DoS-class severity: any client that can run SQL can pin a query worker indefinitely with an unbounded statement. The server process survives, but the query never completes and presumably holds pipeline resources.
- Controls: the identical CTE with
UNIONinstead ofUNION ALL, and the equivalent single-member chain, behave fine on this instance — the hang requires the multi-member cross-generation shape specifically.
Activity
[Bug] Fix multi-member recursive CTE frontier handling (#32828)
XuPeng-SH commentedon Nov 17, 2026
修复已合入 main,转交 QA 验证,不代表验收通过或关闭。
关联 PR:#32828;merge SHA:
43addc16ba30c3e5a0feb11447078092a5fc3953(2026-11-17 08:23 UTC),PR head:a05ccabc2682f69c5343b61af82f2e6bcf3e9c4c。修复范围:recursive member 即使当前 frontier 为空也继续转发 round marker,由共享 recursive sink 在全局 post-DISTINCT frontier 为空时终止;包含 recursive scan 的 join 避开可能让 marker 越过缓冲数据的 shuffle,保留 broadcast 路径。
已有验证证据:PR 作者报告 dispatch/planner 全量 race、嵌入集群取消及 prepared statement 复用回归、2 CN 上 mo-tester 分布式用例 11/11 两轮通过,以及 vet/molint/增量 lint。review 对
74545ab8a1e547bc251d1d1ea95028b89cb7c684的记录为 approve:6 个定向回归、5 个相关包普通测试,dispatch 回归各 100 次,取消/复用 2 次;两个 CN coordinator 各执行 11 条维护 SQL 并断言 6 组精确结果,base-dispatch 负对照按预期失败。首次 planner race 超过 240 秒,未改包后在 600 秒界限内通过。这些是已记录的历史验证,本次仅核对正文、完整评论/review 与补丁,未重新跑测试,不能据此声称最终 merge SHA 已独立复测。QA 边界:复验原始跨代
s IN (0,1)用例及时返回完整 5 行,并覆盖成员换序、多代消费、UNION ALL/DISTINCT 收敛、空轮后重新产出、recursive table join、LIMIT、KILL QUERY 后同一 session/prepared statement 复用;对照 #32612 的后续代行完整性。递归 join 使用 broadcast 可能增加 build-side 内存,不具备 shuffle-only spill/retry;大 build、内存压力与性能未由上述测试证明,应单独验证,不作性能提升承诺。无已核实当前反例或未完成开发 follow-up,交接 Ariznawlll 继续验收。Ariznawlll commentedon Nov 17, 2026
Still reproducing on latest main tip (919c9fc32f) — re-verified 2026-11-17.
Ran the exact 4-member cross-generation repro on a self-built main@919c9fc32f instance (isolated ports;
git_version()confirmed):Actual: the query still hangs with no output, no error, and no
cte_max_recursion_depthtermination — killed the client thread after >60s while MySQL returns the 5 rows in milliseconds; the server survives (SELECT 1works on the same connection afterwards).Additionally re-verified on 4.2-dev tip (
e8fd84b331f): there the query returns instead of hanging, but with wrong rows —(0,1), (1,2), (3,-4)are returned while(2,12)and(3,-3)are missing, i.e. the cross-generation member only produced thes=0-derived row. So main and 4.2-dev exhibit two different failure modes of the same multi-member cross-generation consumption defect (hang vs incomplete rows); neither branch is fixed as of today.Ariznawlll commentedon Nov 18, 2026
验收结论:main 修复有效;4.2-dev 原始问题仍未修复,本 issue 保持 OPEN
本次是对包含 #32828 的 main 实例的新一轮独立复验;不再沿用此前旧实例的超时结论。运行实例均由 SQL 实际查询
git_version(),不是以 worktree HEAD 代替。1. main:原始跨代挂起问题已通过
git_version() = 7fc45a2be2424d887199c5949362855cbacfe30fversion() = 8.0.30-MatrixOne-v1.3.0git merge-base --is-ancestor确认修复 merge commit43addc16ba30c3e5a0feb11447078092a5fc3953在该实例祖先链中。原 issue 的四成员
s IN (0,1)查询已及时返回完整结果,没有客户端超时或服务退出:在独立数据库实际执行
test/distributed/cases/recursive_cte/recursive_cte_multi_member.sql,结果如下:UNION ALLUNION DISTINCT(0,0),(1,1)(0,0),(1,10),(2,30),(3,60),(100,110)LIMIT 1(0,0)另在新 motr 回归中验证成员换序、后续 member 在本地空轮后重新产出、单成员链对照和跨连接重复执行,均符合精确行集预期。
2. 取消、prepared 复用及修复白盒:main 实际 PASS
先通过
-test.list确认测试注册,再执行;没有把[no tests to run]计为通过。pkg/tests/issues/isolated.TestRecursiveCTEMultiMemberCancellationAndPreparedReuse:PASS (4.28s)。该测试启动真实 embedded 1-CN 集群,通过 fault point 阻塞后续 recursive member,由第二连接执行KILL QUERY,断言查询中断错误及 SQLSTATE70100;随后复用同一 prepared statement,计数为 5,connection id 不变且SELECT 1成功。TestDispatchRecursiveCTEMemberForwardsEmptyRoundMarker:PASS。TestDispatchIntermediateForwardsRecursiveRoundMarker:PASS。TestDispatchRecursiveSinkStopsOnlyAfterEmptyGlobalFrontier:PASS。TestCompileRecursiveProbeJoinUsesUnshuffledBroadcast:PASS。TestDetermineShuffleForJoinSkipsRecursiveSubtrees:PASS,包含 remap 前后及 left/right 共 4 个子场景。3. 4.2-dev:原始问题仍有反例,未通过验收
实际连接实例:
git_version() = 7400cae392e90fa94b8cf54dc8520c3c13647884version() = 8.0.30-MatrixOne-v4.2.9执行同一原始
s IN (0,1)查询时,20 秒客户端工具超时前没有查询结果;随后新连接执行select git_version()成功,说明是查询未按预期返回,服务仍存活,不是本次服务 crash 复现。此前该版本的 #32612 原查询又明确只返回(0,10),(1,11),缺(2,14);本轮再次连续执行两次,结果均相同。源码核对:远端
4.2-dev当前为1920dc5c25758003315af6617b6ff6b37bf3fbf7,#32828不在其祖先链中;7400cae392..1920dc5c在dispatch.go/shuffle.go上没有差异。因此这里报告的是修复尚未在 4.2-dev 落地并生效,不是声称已运行1920dc5c实例。请将 main 的修复适配/移植到 4.2-dev;落地后需要重新运行原始挂起及缺行反例。4. motr 回归
14_issue_regression.issue_32799_32612_recursive_cte_members,提交9139e7e16e51caa54abedf56e0c4bac4553a8f16。UNION ALL/DISTINCT、空轮后重新产出、单成员对照、LIMIT、recursive table join 和跨连接重复。run-1794979502515422000:1/1 case PASS,10/10 内部断言 PASS。run-1794979508415319000:1/1 PASS,10/10 内部断言 PASS。run-1794979509820925000:2/2 PASS,累计 20/20 内部断言 PASS,SKIP=0。脚本包装层的stmts=1不代表只运行了一条检查。@target-branch: main,4.2-dev 自然发现为 0 是刻意的未修复隔离,不是 4.2 SKIP 或通过。已知会失败的 4.2 查询未被写成错误 golden 来掩盖问题。5. 范围与交接
本轮是本地单 CN 黑盒加 embedded 1-CN 取消/prepared 集成测试,以及源码 Go 定向测试。没有重新执行真实多 CN 分布式 BVT、重启、race、大 build 内存压力、shuffle-only spill/retry 或性能验证;PR 作者报告的既有 2-CN/race 记录不作为本轮实测。本机 MySQL 对照端口没有服务,本轮没有重跑 MySQL,行集依据原 issue 的确定性递归语义。
最终结论:#32828 在 main 的原始问题和扩展回归通过,但 4.2-dev 仍复现超时/缺行,完整双分支验收不通过,不能关闭。请研发处理 4.2-dev 移植/修复,完成后转 QA 复验。