Skip to content

[Bug]: multi-CN KILL QUERY returns 1105/HY000 instead of 1317/70100 #29693

Closed

Description

@Ariznawlll

MatrixOne version

dce60631f8c857ae730a4d2f328df5962e4f2a8d (current main used for this exploration)

Problem

KILL QUERY cancels an executing multi-CN query, but the client receives the generic error 1105/HY000: context canceled instead of the query-interrupted error 1317/70100.

MatrixOne already defines context cancellation as ErrContextCanceled -> ER_QUERY_INTERRUPTED (1317), SQLSTATE 70100 in pkg/common/moerr/error.go. MySQL also defines ER_QUERY_INTERRUPTED as error 1317 with SQLSTATE 70100 and message Query execution was interrupted.

Reproduction

Create and flush a table with 150,000 rows so that the scan runs on multiple CNs. From session A, record connection_id() and execute a deliberately long aggregate:

select sum(length(payload) + sleep(0.001)) from src;

While the remote pipeline is active, execute this from session B:

kill query <session-A-connection-id>;

The same behavior occurs through both protocol paths:

  1. text COM_QUERY;
  2. binary COM_STMT_PREPARE + COM_STMT_EXECUTE, with the sleep duration bound as a parameter.

Actual behavior

Error 1105 (HY000): context canceled

The query is canceled and remote stream owners are cleaned up. The connection remains usable, and the same prepared statement can be executed again successfully. Therefore the defect is specifically the public error identity returned for the killed query.

Observed on three consecutive prepared executions and one text execution.

Expected behavior

Error 1317 (70100): Query execution was interrupted

The text and binary protocol paths should expose the same MySQL-compatible query-interrupted identity.

Additional evidence

  • After every kill, PipelineMessageSenderGauge and PipelineStreamLifecycleGauge returned to zero.
  • Re-executing the same prepared statement on the same physical connection returned the exact aggregate result.
  • Existing pipeline terminal-failure tests already assert ER_QUERY_INTERRUPTED / SQLSTATE 70100, so 1105/HY000 is inconsistent with MatrixOne's own error contract as well as MySQL.

Activity

  1. added theissue type on Oct 8, 2026
  2. self-assigned this
    on Oct 8, 2026
  3. added a commit that references this issue on Oct 9, 2026
    f5268b1
  4. Ariznawlll commented on Oct 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:MatrixOne 官方 main
    • commit:48dbe277b6d20216c1c513d03c5cbd681380a8a2(执行前后核对 origin/main;修复 PR #29794 的合入提交 f5268b10ad967941fe72d245eedc0b248e372172 是其祖先)
    • 部署方式:本机独立测试实例;原 SQL 走 2 CN / 1 TN / 1 LogService,另用 MatrixOne 嵌入式集成测试强制 3 CN 远程扫描及管道;未使用共享 TKE/128/129。
    • 测试日期:2026-10-16

    原问题验证

    1. 建表并写入、flush 150,000 行;count(*)=150000,sum(length(payload))=4800000。会话 A 执行原始 select sum(length(payload) + sleep(0.001)) from src,会话 B 在 SHOW PROCESSLIST 确认执行中后发送 KILL QUERY <A 的 connection_id()>。
    2. 分别走文本 COM_QUERY 和二进制 COM_STMT_PREPARE/COM_STMT_EXECUTE(sleep(?) 绑定 0.001)。完整重复 3 轮,两条路径每轮均返回 MySQL error 1317 / SQLSTATE 70100,不再返回 1105/HY000。
    3. 在同一物理连接上继续执行正常查询,预处理路径复用同一个 statement、将参数改为 0,两条路径均返回精确聚合值 4800000;连接 ID 未变化。测试库已按精确名称删除。
    4. 重复期间有一次本机第 2 CN 后端重启窗口,单次预处理执行返回 20505/HY000 ... 127.0.0.1:18047 connect: connection refused;监听端口恢复后重跑通过。该次归类为本机环境瞬断,不计作产品修复通过次数,也不掩盖该异常。

    Happy Path 覆盖

    1. 取消后正常聚合返回 4800000,同一连接及同一预处理语句可继续使用,3/3。
    2. 嵌入式 3 CN 用例中,强制多 CN 扫描后 24,576 行的正常 percentile_cont/disc 分别精确返回 12288.5/12288,三 CN 查询均一致。

    Unhappy Path 覆盖

    1. 文本与二进制协议的运行中查询被跨会话取消:均是 1317/70100;本机原始 SQL 各 3/3,3 CN 强制远程管道集成测试各 10/10。
    2. 3 CN 集成测试每次取消后 PipelineMessageSenderGauge 与 PipelineStreamLifecycleGauge 均回到 0;同连接/statement 再执行正确,未见远程 stream owner 残留。

    白盒验证

    • 在同一 SHA 执行 TestIssue29492MultiCNCancellationCleanup,-count=3 和 -count=7 均通过,合计 10/10。该测试明确强制 3 CN 扫描、等待远程 sender 活跃后取消,覆盖文本及预处理协议和上述资源释放断言;未执行 -race,本 issue 的公开错误身份不依赖 race 检测。

    回归测试

    • 已补入同一 MOTR 汇总 PR matrixorigin/motr#237:Go 协议场景、入口脚本及预期输出。默认场景验证文本及二进制协议 1317/70100 与同连接恢复;场景还支持对原始 15 万行 SQL 的本地复测。
    • ./motr 14_issue_regression.issue_29693_kill_query_wire --repeat 3 -j 1:3/3 通过,3/3 场景语句通过;go vet 通过。PR (AOE) incompatible bug fix #237 尚未合入,完整 suite/集成 CI 尚未验证,后续继续跟踪,不能把这些未执行项称为通过。

    测试证据

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions