Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues. Searches for "recursive cte crash", "server crash", "process killed recursive" returned nothing matching this plan-time failure.
Branch Name
- main (worktree at HEAD of main)
Commit ID
e2459cc55f4b514893e19732743460bc5f16d552(2026-11-09 build,mo-service)
Other Environment Information
- Hardware parameters: Apple M-series (arm64), 16 GiB RAM
- OS type: macOS (darwin arm64)
- Single-node launch config (
-launch etc/launch.toml, one CN + one TN + logservice via local fileservice)
Current Behavior
A single SQL statement kills the entire server process (CN + TN + logservice in one mo-service process — nothing survives, the port stops listening, and a full restart is required):
WITH RECURSIVE qn AS (SELECT 1 FROM qn UNION ALL SELECT 1 FROM qn)
SELECT * FROM qn;Observed sequence on the client:
- Query hangs for ~15 s, then the connection dies with
(2013, 'Lost connection to MySQL server during query') - The
mo-serviceprocess is gone (psshows nothing; port 26001 stops listening) - Every subsequent connection attempt fails with
(2003, Connection refused)until manually restarted
Reproduced twice with 100% determinism, plus once more during an official-suite replay (this exact statement is item #7 of the official mysql-test/include/with_recursive.inc, which is how it was first discovered — the remaining 150 statements of that file run fine).
Expected Behavior
MySQL 8.3 semantics: this statement is invalid SQL usage (the recursive union branch references the CTE in a non-recursive position), and MySQL rejects it at plan time with an error such as:
ERROR 1146 (42S02): Table 'test.qn' doesn't exist
The correct MO behavior is any plan/parse-time rejection — never a process kill. A single client-supplied query expression should never be able to take down the whole database node (availability DoS).
Steps to Reproduce
# pip install pymysql
import pymysql, time
conn = pymysql.connect(host='127.0.0.1', port=26001, user='root', password='111',
autocommit=True, connect_timeout=5, read_timeout=25)
cur = conn.cursor()
cur.execute("""
WITH RECURSIVE qn AS (SELECT 1 FROM qn UNION ALL SELECT 1 FROM qn)
SELECT * FROM qn
""") # <-- server fully dies hereThen verify the process is dead:
lsof -i :26001 -P -n | grep LISTEN # nothing
ps aux | grep mo-service # nothingMinimal characterization of the crater:
WITH RECURSIVE qn AS (SELECT 1 AS a UNION ALL SELECT 1 FROM qn) SELECT * FROM qn— works fine (a proper seed branch exists). The crash requires the seed branch itself to referenceqn(SELECT ... FROM qnin the non-recursive member).WITH RECURSIVE qn AS (SELECT 1 FROM qn) SELECT * FROM qn(no UNION at all) — rejected at parse time with "In recursive query block ...", no crash.- So the trigger is: plan-time passage of a non-terminating pure self-reference that only unfolds inside the union-all branch shape — the check that guards the non-union form does not cover the union shape.
Additional Statements / Logs
No panic message or stack trace was emitted to fd before death (the process vanished without logging a panic — itself worth investigating: kill -9-style exit, no graceful shutdown log lines either). Startup logs before the crash show normal operation; after restart with the same data directory the cluster comes back cleanly (no data corruption observed).
Activity
XuPeng-SH commentedon Nov 29, 2026
Fixed on
mainby #32831 (27bb33d97b), which also addresses the duplicate report #32795. The planner now rejects an invalid recursive CTE anchor before it can re-enter binding. The merged PR reports SQL error 1064 and successful reuse of the same connection after the error.On
mainat6540533196, seven focused planner checks passed under the race detector. MySQL TCP validation also passed for finite recursion, prepared statement reuse with different parameters, and a subsequent query on the same connection.@Ariznawlll, please verify this on a
mainbuild that includes #32831 and confirm that the connection remains usable after the planner returns the validation error.Ariznawlll commentedon Nov 29, 2026
结论
测试通过。本轮“递归 CTE 缺少合法 anchor 导致服务退出”已完成下列原始复现、相关扩展及对应 Linux CI;回归已提交至现有 MOTR PR,按授权关闭。
关键证据
版本与修复范围
6540533196711f09e6b1279066063cb90043ebd8,独立目录编译、独立端口/数据目录;两个 CN 的SELECT git_version()与完整 SHA 一致。27bb33d97b35c581b11775cb1ffbcbd41de35139。实际执行步骤与结果
TestRecursiveCteAnchorReentry三轮通过,包含独立子进程与受控栈边界,避免只凭 SQL 错误判断服务安全。回归与 CI
e75a4d2ca470b35c2bf254cfcf5e3069f51be90a,不是仅依据分支名称。六组正式 MOTR × 3 轮,共 18/18(0 SKIP);plan、blockio、fulltext、vector metric 定向源码测试,以及 frontend native prepared SHOW 和 sqlintegration 角色规则测试均-count=3通过。待解决点
本 Issue 所列验收范围内无待解决的产品失败。MOTR PR 尚待合入;已获得“回归提交后可先关闭”的授权。本结论不外推到未涉及的性能、大数据或其他 Issue。
最终结论:测试通过。上述原始与扩展场景、对应分支回归及 Linux CI 均通过;未通过项:无。回归已提交现有 MOTR PR,本次关闭 #32601。