Repository navigation
Description
Description
mo_ctl('cn', 'reader', '<arg>') panics with a Go slice-bounds panic on any input that doesn't split into at least three :-separated parts. From the source at pkg/sql/plan/function/ctl/reader.go (line ~64), the handler indexes args[2] before validating length, so inputs with only 2 parts raise runtime error: index out of range:
SELECT mo_ctl('cn', 'reader', '');
-- ERROR 20101: internal error: panic runtime error: index out of range [1] with length 1
SELECT mo_ctl('cn', 'reader', 'lkt.t');
-- ERROR 20101: internal error: panic runtime error: index out of range [2] with length 1: runtime.panicBounds64
Per the (scarcely documented) semantics at the comment header of reader.go, the expected form is enable|disable:force_build_remote_ds|force_shuffle:tid1,tid2[:blk_cnt]. But any typo, missing colon, or placeholder — e.g. a DBA trying the obvious mo_ctl('cn', 'reader', 'lkt.t') — produces a runtime panic, which SQL clients surfaces as a generic "internal error" with a leaked Go stack:
runtime.panicBounds64
/Users/ariznawl/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:236
The surviving CN process does recover (the panic is caught by the panic-handler and returned as the internal error), so this is not a crash-cluster incident, but it's an uncaught assertion path inside a built-in administrative function, and the stack-trace leak exposes internal build paths/temp dirs to SQL clients.
Reproduction
SELECT mo_ctl('cn', 'reader', ''); -- panic index out of range [1] with length 1
SELECT mo_ctl('cn', 'reader', 'lkt.t'); -- panic index out of range [2] with length 1
SELECT mo_ctl('cn', 'reader', 'a:b'); -- panic index out of range [2] with length 1
-- valid form (no panic):
-- SELECT mo_ctl('cn', 'reader', 'enable:force_build_remote_ds:1,2');Impact
- Any DBA probing the admin command or mistyping the argument shape sees a Go runtime panic + internal stack trace. Filed bugs often come out of "I ran the documented mo_ctl and got an internal error: index out of range".
- Stack leak: error message carries absolute build path (
/Users/ariznawl/go/pkg/mod/...) — a security/credibility issue in diagnostic output. - Not a crash, but identical signature can mask real panics elsewhere in the same handler.
Expected behavior
Length-validate args before indexing and return a clean invalid input-family error (201xx) with the expected format hint, matching how neighboring handlers (LABEL, WORKSTATE) already handle wrong shapes.
Activity
fix(ctl): reject short mo_ctl reader args with explicit invalid input (…
XuPeng-SH commentedon Oct 28, 2026
QA status for merged main
d5d1c5c8cc30055635840874768286457ceb5b08(#31528): no current-head ctl package or SQL protocol test was run in this environment; available headroom under the existing guard is insufficient for a safe large link or current-head service. Empty/short parameters, valid commands and same-session recovery remain pending independent verification. The PR reports separate author-run component and single-CN SQL tests; its forwarding check was simulated, not a live multi-CN run. Existing tester assignment unchanged.Ariznawlll commentedon Oct 28, 2026
结论
测试通过。
mo_ctl('cn','reader',...)对原始短参数返回明确的 invalid input,不再向客户端暴露 slice 越界 panic;合法命令可向各 CN 转发。关键证据
main@4808a7befd38cc877606f1c7ceda41ff387b212e包含已合入修复 #31528 的 merge commit51d27a44a17dca2cad71853a52859437426b902b;macOS arm64,隔离 Log、TN、两个 CN 分别运行独立进程,CN 实际git_version()均为4808a7befd。''、'lkt.t'、'a:b'每个入口均 3/3 返回 20301,错误无panic/index out of range,每次同连接SELECT 42正常;合法force_build_remote_ds和force_shuffle的 enable/disable 均核对返回包含两个 CN 成功结果,分别 3/3,结束时关闭测试设置。TestMoCtlReaderRejectsShortParams、AppliesValidParams、ForwardsWellFormedParams重复 3 次通过;MOTR #287 加入短参数及会话复用回归,定向 3/3。MOTR PR 离线检查通过;修复 PR 的 UT、SCA、多 CN BVT 和 CI Required 通过,队列规则单项失败、若干禁用项 skipped。待解决点
无;本轮未自行运行完整 MOTR suite 或完整产品 CI,合法设置仅在隔离测试环境执行并复位。