Skip to content

[Bug]: LoopJoin/LIKE keeps executing after cancellation with long-lived transactions and high CN CPU (4.2.6) #30836

Done

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Related: #30387 (4.1.5 client-disconnect detection), and #26067 (Window/UNION cancellation). This report tracks a different, observed boundary: the deployed frontend already detects the disconnected client and invokes cancellation, but a CPU-bound LoopJoin/LIKE execution remains alive afterward. It should not be closed solely because disconnect detection or Window cancellation is implemented.

The Window/Partition fix #26080 (merge commit 4389315727e0176764b91dd1f88e9f2f705a72ee) is already an ancestor of the affected commit; its changes do not cover LoopJoin.scanProbeMatches.

Branch Name

4.2 release line; observed image v4.2.6-71498157cc-2026-10-20. Other branches and an introducing commit have not been established.

Commit ID

71498157cc21f833b8e717f45d50d1f926be3134

Other Environment Information

  • Internal IDC QA, distributed MatrixOne on Kubernetes, application connections through MO Proxy.
  • Affected TP CN resource limits: 16 CPU / 55 GiB memory each.
  • Workload: MOI Catalog background orphan-file reference checking, not an Astra-issued query established by this investigation.
  • Investigation was read-only: no new load, KILL, CN restart, or product patch was executed to obtain this evidence.
  • Connection/transaction/statement identifiers below are diagnostic correlation keys. Account/user names, addresses, credentials, and application payloads are omitted.

Actual Behavior

Long-running correlated NOT EXISTS queries with dynamic LIKE predicates keep executing in LoopJoin.scanProbeMatches. In two earlier observations, the frontend explicitly logged cancellation after client disconnect, yet the same transaction remained active afterward. One remained active 90 minutes after the cancellation log; a post-cancellation goroutine dump still showed its execution worker running LIKE/regexp inside LoopJoin.

A later recurrence remained COM_QUERY for more than five hours on a CN consuming approximately 15.1 of its 16 CPU cores. The operator reports that KILL did not terminate it. We independently verified the continuing statement and CPU usage, but have not captured the exact KILL command/response or its arrival at the owning CN for this later recurrence. The primary cancellation-failure evidence is therefore the earlier frontend-disconnect timeline, not an assumption that this later KILL was delivered.

Observed timeline

All dates/times below are UTC. Asia/Shanghai is UTC+08:00.

Execution Event UTC timestamp Asia/Shanghai
A, connection 163263046 Transaction created 2026-10-21 17:55:18.611371 Oct 22 01:55:18
A Frontend logged client-disconnect cancellation 2026-10-22 01:51:52.452890 Oct 22 09:51:52
A Same transaction still reported active 2026-10-22 03:22:12.705298 Oct 22 11:22:12
B, connection 163348400 Transaction created 2026-10-22 01:53:59.389788 Oct 22 09:53:59
B Frontend logged client-disconnect cancellation 2026-10-22 03:19:54.094591 Oct 22 11:19:54
B Same transaction still reported active 2026-10-22 03:24:11.468497 Oct 22 11:24:11
C, connection 163396670 Current statement started 2026-10-22 04:44:13.745019 Oct 22 12:44:13
C Independent processlist check: still same statement/transaction Approximately 2026-10-22 10:02 Approximately Oct 22 18:02

Correlation keys:

  • A: txn 6e542047007fda5718e042c9b61e7e42, statement 01a15f9a-73fd-7cae-8894-1e7d8d584001, frontend goroutine 71118407.
  • B: txn bb3bbf26f8789ad218e0992801eb2b29, statement 01a16150-af14-733e-96b3-b755afb81d7f, frontend goroutine 59072223.
  • C: txn 36806d64829cdd1f18e0bd3cbb8b0c0d, statement 01a161ec-877a-72dd-9166-c9b23528d479.

Redacted raw event excerpts (the peer endpoints were correlated privately to the connection IDs):

2026/10/22 01:51:52.452890 +0000
frontend/routine_manager.go:229
cancel active query after client disconnect: connection=<A proxy peer>

2026/10/22 03:22:12.705298 +0000
cn-service found leak txn
txn-id=6e542047007fda5718e042c9b61e7e42
create-at=2026/10/21 17:55:18.611371 +0000
ConnectionID=163263046

2026/10/22 03:19:54.094591 +0000
frontend/routine_manager.go:229
cancel active query after client disconnect: connection=<B proxy peer>

2026/10/22 03:24:11.468497 +0000
cn-service found leak txn
txn-id=bb3bbf26f8789ad218e0992801eb2b29
ConnectionID=163348400

found leak txn is the detector's log wording, not proof of an allocation leak.

Execution evidence

For A, a goroutine dump taken after the frontend cancellation contains:

frontend goroutine 71118407 [chan receive, 555 minutes]
  -> compile.(*Compile).runOnce
     waiting for execution scopes

worker goroutine 71259177 [runnable]
  regexp.(*machine).step / match
  regexp.(*Regexp).Match
  function.(*regexpSet).regularMatchForLikeOpWithEscape
      func_builtin_regexp.go:765
  function.opBinaryBytesBytesToFixedWithErrorCheck
      baseTemplate.go:2086
  colexec.(*FunctionExpressionExecutor).Eval
      evalExpression.go:1117
  loopjoin.(*container).evalConditionWindow
      probe.go:187
  loopjoin.(*container).scanProbeMatches
      probe.go:311
  loopjoin.(*container).probe
      probe.go:400
  loopjoin.(*LoopJoin).Call
      join.go:165
  vm.Exec
      types.go:378
  ...
  compile.(*Scope).Run(..., 0x266b4214908)

The frontend and worker stacks were linked through the same Compile instance (0x266b4214908), rather than attributing an arbitrary pod-wide regexp stack to this transaction.

For B, the corresponding Compile instance had 15 worker stacks containing LoopJoin; 13 were in regexp-related execution at sampling. Its CN CPU rose from approximately 5.97 cores in the 01:30–01:50 UTC pre-query window to 15.45 cores in the 02:00–03:08 UTC window. This establishes significant resource pressure, not that every CPU cycle on the CN belongs to this query.

Expected Behavior

Once query cancellation is delivered, CPU-bound execution should observe it within a bounded amount of work and unwind. Query scopes, transaction/session cleanup, and their owned resources should not remain blocked for tens of minutes or hours behind a non-yielding operator.

The query may legitimately be expensive, but that does not justify ignoring cancellation. KILL returning OK, a connection disappearing from a view, or changing QueryInExecute is not by itself proof that execution and cleanup have finished.

Steps to Reproduce

Observed real-workload trigger: MOI orphan-file cleanup constructs a correlated anti-join over file candidates and persisted message/snapshot text, plus other reference checks. The actual processlist SQL for C begins with this structure:

SELECT f.file_id
FROM `file` AS f
WHERE ((f.ref_count = 0 AND f.created_at <= <retention_cutoff>)
    OR (f.ref_count = -1 AND f.updated_at <= <claim_cutoff>))
  AND f.source <> 'builtin'
  AND NOT EXISTS (
    SELECT 1 FROM data_asset AS da
    WHERE da.asset_type = 'file' AND da.asset_ref = f.file_id
  )
  AND NOT EXISTS (
    SELECT 1 FROM agent_runtime_messages AS arm
    WHERE arm.parts_json LIKE CONCAT('%', '"', f.file_id, '"', '%')
       OR arm.parts_json LIKE CONCAT('%moi://files/', f.file_id, '%')
  )
  AND NOT EXISTS (
    SELECT 1 FROM agent_runtime_turn_snapshots AS arts
    WHERE arts.snapshot_json LIKE CONCAT('%', '"', f.file_id, '"', '%')
       OR arts.snapshot_json LIKE CONCAT('%moi://files/', f.file_id, '%')
  )
  /* Additional reference checks omitted. */
ORDER BY f.file_id
LIMIT 100;

This is an abbreviated query shape with placeholders, not a complete executable reproduction. The captured processlist text was truncated; the ORDER/LIMIT and further reference checks were verified against the application source. LIMIT 100 bounds returned candidates, not the work performed by the correlated predicates.

For an isolated reproducer/regression test:

  1. Use the affected MO commit and synthetic file IDs plus long message/snapshot text. Arrange a sufficiently expensive non-equi SEMI/ANTI LoopJoin, including no-match cases; verify the actual operator path rather than assuming the SQL always selects it.
  2. Start the query and establish that a worker has entered scanProbeMatches/LIKE evaluation.
  3. In separate runs, exercise client disconnect, KILL QUERY, and KILL CONNECTION. Correlate the cancellation with the exact owning CN and statement.
  4. Assert bounded execution exit, transaction cleanup, and stable owned-memory/worker baselines after repeated cancellation.

Not yet performed: a deterministic synthetic reproduction or before/after patch validation. Do not replay the expensive query on a shared QA/production cluster to reproduce this report.

Additional information

Exact-version code analysis

The strongest code-level explanation is a cancellation-observation gap in long LoopJoin scans:

  • RoutineManager.cancelDisconnectedRequests emits the observed log and invokes routine.beginClose().
  • Routine.beginClose invokes the current request cancellation function.
  • vm.Exec checks cancellation before op.Call(proc).
  • scanProbeMatches scans build batches, condition windows, and rows without checking proc.Ctx in those loops. Its comment explicitly states that it does not yield midway.
  • probe invokes that scanning path for SEMI/ANTI/MARK/SINGLE. An output-batch bound is not a bound on the amount of unsuccessful matching work within one Call.
  • The sampled expression path uses FunctionExpressionExecutor.Eval and LIKE/regexp matching; the generic Eval path does not supply an inner-loop cancellation boundary.
  • Compile.runOnce waits for scope completion. The observed stuck parent and still-running worker are consistent with this lifecycle.

This is observed cancellation failure with a strongly supported implementation hypothesis. A controlled regression test is still needed to establish the complete fix boundary; we have not experimentally proved that adding one check alone resolves every cancellation path.

Scope and non-claims

  • This report is about cancellation responsiveness and delayed resource cleanup, not a demonstrated new memory leak, OOM, data corruption, or identified regression-introducing commit.
  • MOI's expensive background query and missing effective execution budget are separate application-side contributors. They do not remove MO's responsibility to honor cancellation.
  • [Bug]: in-flight statements are never cancelled when client connection closes mid-execution (4.1.5) — zombie query pileup, throughput collapse, CN OOM loop #30387 primarily describes a 4.1.5 path that does not detect a client disconnect during execution. Here the frontend detection/cancellation log is present; executor responsiveness is the remaining boundary to investigate.
  • For recurrence C, preserve the operator's KILL report but do not equate it with independently verified delivery. Bare KILL <id> means CONNECTION in this version; repeated identical commands do not provide a stronger interruption mechanism.
  • The investigation did not restart CNs. Earlier affected CNs were replaced by other environment operations; this is not a before/after product-fix validation.

Suggested acceptance criteria

  • Deterministically cancel after entering the expensive scan, not only before Call.
  • Cover no-match and match-heavy SEMI/ANTI paths and review the shared MARK/SINGLE paths; do not rely only on output-row limits.
  • Verify client-disconnect and explicit KILL paths independently, with cancellation delivery and execution exit both witnessed.
  • Verify reset/free/transaction cleanup and repeated-run memory/worker baselines, with no premature freeing of buffers still used by executing workers.
  • Preserve ordinary query results and normal early-completion semantics. Do not merely hide the session or return from the parent while leaving workers running.

Activity

  1. added
    severity/s0
    and removed on Oct 22, 2026
  2. LeftHandCold commented on Oct 22, 2026

    @LeftHandCold
    CollaboratorAuthor

    根因确认与修复验收(2026-10-22)

    已经确认是 MO 执行层的合作式取消缺口,不只是 SQL 较慢、负载繁忙或 Runner 误报。

    修复 PR:

    1. 已敲定的因果链

    1. Frontend 的取消已经传到 request/query/pipeline context,不需要再加一个取消控制器。
    2. vm.Exec 只在调用 operator 前检查取消,不能抢占已经进入的 LoopJoin.Call。
    3. 无匹配的 correlated NOT EXISTS/LIKE 可以在一次 Call 内持续扫描 probe/build batches;没有结果不代表没有工作。LIMIT 100 只限制输出,并不限制证明 NOT EXISTS 所需的扫描。
    4. 一次 LIKE expression Eval 本身又可以连续执行大量 regexp matches,原路径同样不观察取消。
    5. 因而收到取消之后,LoopJoin worker 仍占 CPU,Compile 仍等 worker 返回,原事务也不能完成清理。这与 issue 中同一 statement/txn/worker 在明确 cancel 之后继续执行的现场证据一致。

    Main 和当前 4.2 都存在该缺口。源码历史表明,当前 scanProbeMatches 抽取之前的 LoopJoin 也缺少相应检查;不能据此认定某个最近 PR 首次引入回归。本次也没有把 long-lived txn 日志扩大解释成已证明的内存泄漏。

    2. 4.2 严格同版本前后验证

    在 50 的独立实例验证,没有改动现有 QA、回归或客户服务。

    • Before:干净 4.2-dev@26d3a200cb13f4be3b5f64d489bac75d8dcc5814。
    • After:同一 base 加 fix(sql): honor LoopJoin and LIKE cancellation on 4.2 #30863。
    • 两边相同资源:1 CN、2 CPU、6GiB;相同固定数据:1,024 file 行、2,048 docs 行,每行 4,096 bytes,约 8MiB text。
    • 相同 correlated NOT EXISTS + 两个 LIKE 分支 + ORDER BY/LIMIT 形状。
    • 发起取消前,实际观察到同一 connection/statement/transaction,以及同一个 goroutine 的 LoopJoin + LIKE/regexp 执行栈。
    操作 Before After:服务端实际退出
    KILL QUERY KILL 立即返回 OK,20 秒后原事务及原 LoopJoin worker 仍在 126ms:原事务消失、worker 离开 Scope;原连接可继续查询
    KILL CONNECTION KILL 立即返回 OK,20 秒后原事务及原 worker 仍在 125ms:session/txn 消失,原 worker 离开 Scope
    客户端断开 frontend 明确记录该 peer 的 cancel;17.66 秒后原事务/worker 仍在 断开后 2423ms 清理完成;从明确 frontend cancel 日志算约 42ms

    4.2 的既有断连检测有 30 秒 query-age grace 和 5 秒探测周期。因此实验在查询年龄达到 31 秒并重新确认原执行现场后才断开;没有把检测资格等待与执行器响应延迟混为一谈,也没有改变这个策略。

    每个 After 场景均进一步检查:原 txn count=0、没有残留 LoopJoin worker、原 worker 已离开 Scope、相同正常查询返回固定答案 missing、SELECT 1 正常,以及 fixture 数据库清理后不存在。客户端返回错误本身不作为服务端清理成功的证明。

    4.2 KILL 返回既有 1105/HY000: context canceled;Main 验收返回 1317/70100: context canceled。没有顺带修改两分支的错误码策略。

    二进制 SHA256:

    4.2 before  36a438298c019e7e6a4f1030784d25e18c277c23552483fcc52d57c288bb3450
    4.2 after   2f9b56bf5f8f3f269e0d76d1f35f06127a9810c75e46c8c794ef57f15b0a5d8c
    Main after  ce9fd6c6f0c71a39beaa7a8a3ced277b95545001f9d6b15d507da6b5c52e8a90
    

    Main 候选的同三入口公共验收也全部通过,观测清理时间分别为 126ms、140ms、834ms。但 Main 没有做 public baseline 对照,不把跨分支比较冒充同版本 A/B;其缺陷另有源码和修复前 UT 负例证明。

    3. 修复范围与风险控制

    • 在现有 LoopJoin 工作边界、条件计算前后观察同一个 context;Main 同时覆盖 PairCondition 的返回/挂起路径。
    • 文本 LIKE 在每次真正 regexp match 之间检查取消,现有便宜向量 fast path 每 256 行检查一次。
    • 修正临时 condition window 的错误路径所有权:显式 nil 返回值不能提前清空 defer 所依赖的唯一指针。
    • 不改 SQL 匹配语义、NULL/selection、cache 算法、batch limits、Reset/Free;不新增后台线程、定时器、状态机或配额。
    • 4.2 没有照搬 Main 专属 continuation、binary-string 或 Unicode/escape 语义变化。

    两分支 owning-package 普通测试、race、各精确取消测试独立 race×100、Go vet、配置对应的 lint、完整服务编译全部通过。测试还覆盖普通正确结果、真实 window 释放、重复清理和同一个 operator 在新 context 下复用。Main 36 个 LIKE benchmark cell 的三组交替前后对照无新增 allocation;真实 cancellable context 最大 median 增量约 0.51ns/row。该微基准不承诺所有业务零性能变化。

    4. 边界与当前状态

    这是取消已经送达后仍继续执行的修复,不是把原本昂贵的 NOT EXISTS/LIKE 查询改写成快查询。单次正在执行的 Go regexp 匹配仍不可异步抢占,因此不承诺任意超大单行的固定毫秒取消 SLA,也不声称已经验证所有跨 CN 取消投递情形。

    全部自有验收实例已停止。4.2 容器在独立的 2 秒停止 grace 后可能 exit137,但 OOMKilled=false;这发生在已经证明请求/事务/fixture 清理之后,未混作查询退出证据。

    本地修复验收通过,PR CI/review 和实际版本合入/部署仍待完成。暂不关闭 issue。

  3. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Main-branch regression follow-up — PR #30862

    The latest review of PR #30862 (8bd800cf9fa4c07c16986d7dd7d543f913545cce) found a separate request-context regression in the Main candidate. I independently inspected the linked GitHub Actions artifacts from run 39773539184:

    • Compose/PROXY BVT: charset_collation_basic.sql:23 (SHOW COLLATION ... LIKE '%bin%') and operator/like_operator.sql:237 (SHOW VARIABLES ... ILIKE '%matrixone%') both returned context canceled instead of normal rows.
    • Multi-CN pessimistic BVT: system_variable/system_variables.sql:76 (SHOW VARIABLES ... LIKE 'system%') returned context canceled.

    These are ordinary SHOW statements, not cancellations initiated by the test. The review traces this to a stale canceled proc.Ctx on a reused frontend Process; it requests refreshing the execution context at the request boundary while preserving cancellation of the current request. This blocks the Main PR at that head.

    This is distinct from the 4.2.6 defect tracked here: PR #30863 adds ResetQueryContext at the request boundary and the latest review of its head reports no code blocker. The issue is now assigned solely to Ariznawlll for tester verification; LeftHandCold was removed as part of the transfer. The issue remains open because the separate Main-branch follow-up is not complete.

    Merge follow-up (2026-10-22)

    PR #30863 is now merged: reviewed head aa160a4d3fa382aa3707c81d069e3a0114e6fe57, merge commit 17f4f87ea0bee9c7b6641b5c12c87e741cdd8321. The latest review reports targeted cancellation/context tests and the public SQL regression passing; it also reports the changed owning-package race tests, coverage UT, SCA, Compose PROXY and Pessimistic BVT passing. These are GitHub/reviewer records, not tests I reran locally.

    The exact merge commit has no combined status entries or PR-triggered workflow runs available through the GitHub data checked. The review separately records a race-UT failure in TestGlobalCheckpoint2; it is not attributed to the changed SQL paths, but the required CI gate should be checked independently.

    PR #30862 remains open at head 1628328874a039b52961c8aef290052811ed3a1c, so the Main-branch half of this issue is not complete. Keep issue #30836 open because the Main-branch follow-up is not complete. Ariznawlll is the sole assignee for tester verification; LeftHandCold was removed.

  4. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    QA follow-up — main fix PR #30862 head d436f4fd5dbd6c6df4ff7dd4731151d87acc5b2d (2026-10-22)

    This head adds a scoped frontend-expression context binding/restoration for SHOW filters, prepared SET/simple expressions and meta_scan privilege argument evaluation, alongside cancellation checks in LoopJoin and LIKE. Static inspection finds the earlier stale-proc.Ctx issue addressed in the changed call sites: each evaluation defers restoration of the exact previous context, and executor/result cleanup is deferred before the context is restored. LoopJoin checks cancellation at Call/work boundaries and preserves condition-window cleanup; LIKE checks cancellation at row batches and before each regexp match. One running regexp match remains non-preemptible, as the PR documents.

    The PR author reports owning-package, full frontend, race, coverage-mode and lint passes, including the prior SHOW/LIKE and compiler-context regressions. I did not execute those tests: this workspace is not a MatrixOne checkout and has no Go binary. Exact-head GitHub status has zero commit statuses; the returned Connector/J Pool Reset E2E is still running and Iceberg Connector E2E passed, neither being a targeted result for this change.

    No additional actionable finding was established by this static pass. Keep #30836 open pending exact-head required CI and independent frontend/LoopJoin/LIKE tests; its current tester assignee Ariznawlll is unchanged.

  5. Ariznawlll commented on Oct 23, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:d4c37f4d8722dd91b80f5f5547940004bf1b293f
    • 部署方式:独立本地 1 CN / 1 TN / 1 LOG,直连 CN;未修改产品源码的本地构建,运行时 git_version 与源码 SHA 一致。
    • 测试日期:2026-10-23;Connector/J 8.4.0。

    原问题验证

    补充当前 main 的二进制 prepared + JDBC timeout + 客户端断开后残留执行边界,不是对 #30862 PR head 的修复验收。

    CREATE TABLE cj(id INT PRIMARY KEY,s VARCHAR(30));
    INSERT INTO cj
    SELECT result,CONCAT('v',LPAD(CAST(result AS CHAR),6,'0'))
    FROM generate_series(1,40000) g;
    
    -- 使用同一个 server-side PreparedStatement:
    SELECT COUNT(*)
    FROM cj l JOIN cj r ON l.s LIKE CONCAT(r.s,'%')
    WHERE l.id<=? AND r.id<=?;

    JDBC 参数:useServerPrepStmts=true&cachePrepStmts=false&socketTimeout=30000。

    1. 绑定 (10,10),正确返回 10。
    2. 同句柄 setQueryTimeout(1),改绑 (40000,40000)。
    3. 三个新建连接分别在 30011 / 30089 / 30053 ms 后抛 CommunicationsException / 08S01,不是在 1 秒附近结束。
    4. 客户端已关闭后,服务端 processlist 仍显示原连接/事务执行同一条 prepared SELECT。下表时间为 Asia/Shanghai:
    连接 查询开始 11:13:20 检查
    443 11:11:19 仍为 COM_STMT_EXECUTE,同一事务
    445 11:11:49 仍为 COM_STMT_EXECUTE,同一事务
    448 11:12:19 仍为 COM_STMT_EXECUTE,同一事务

    查询计划是 Aggregate -> INNER Join (l.s LIKE CONCAT(r.s,'%')) -> 两侧 Table Scan,不是等值 hash join 的简单对照。

    Happy Path 覆盖

    1. 每次大查询前,小参数 (10,10) 返回精确计数 10。
    2. 初始源表 COUNT(*)=40000、SUM(id)=800020000。
    3. 同批次此前的 prepared SLEEP(?)、1 秒 JDBC timeout、随后同句柄 SLEEP(0) 和 SELECT 1,3 次均正常取消并恢复。这说明不应将所有 JDBC timeout 都一概认定失效。

    Unhappy Path 覆盖

    1. 上述 JOIN 1 秒超时,3/3 最终落到约30秒 socket timeout;没有把客户端异常当成服务端已清理。
    2. 客户端关闭之后仍能看到原服务端执行。后续 KILL QUERY 443 返回 20101/HY000: internal error: cannot kill a closed or changing session。本次无法证明这个额外 KILL 已送达执行器;不将其写成“已成功 KILL 后仍运行”的证据。
    3. LEFT JOIN 同形查询已启动,客户端被主动终止后也观察到服务端残留,但未完成3次,因此仅作补充观察。窗口分支尚未执行,不能算已覆盖。
    4. 为避免叠加残留大查询,已停止测试客户端;测试用户、角色、数据库清理命令均成功。随后停止并重启本轮自建隔离实例释放残留执行,不涉及共享环境。TERM 后日志出现 shutdown role still draining(CN,1m0s),最后 panic: context deadline exceeded,进程 exit 2。准备强制结束时该 PID 已不存在,实际没有执行成功的强制终止。重启后 SHA 不变,测试库已不存在、SELECT 1 正常。此关闭超时作为残留执行期间的观察,未计为单独新 bug。

    白盒验证

    检查本提交 pkg/sql/colexec/loopjoin/join.go 的 Call/Probe 路径、probe.go 的外层 probe 循环与动态 LIKE 条件求值。与本 issue 讨论的取消观察缺口吻合。未应用 PR #30862,未进行内部注入或声称已经验证其最新 head;不另开重复 issue。

    回归测试

    本轮仅运行隔离复现脚本,未添加仓库 case/PR。建议现有修复验收补充 server-prepared JDBC 超时、同句柄小→大、客户端断开后的服务端会话/事务退出;不能仅验证客户端收到异常。

    测试证据

    客户端原始输出摘录:

    CommunicationsException:0:08S01:Communications link failure
    elapsed_ms=30011
    elapsed_ms=30089
    elapsed_ms=30053
    

    服务端第一条残留执行:

    conn_id=443
    statement_id=01a166bd-d3dd-7090-807c-3de6126df690
    txn_id=ef2ad5be0d96bbda18e108df9c276806
    command=COM_STMT_EXECUTE
    parameters=40000,40000
    query_start=2026-10-23 03:11:19.005900 UTC
    still present at=2026-10-23 03:13:20 UTC
    

    测试结论

    测试不通过。

  6. Ariznawlll commented on Oct 26, 2026

    @Ariznawlll
    Collaborator

    阶段性 QA 记录(待 TKE 原场景复验,非最终验收结论)

    版本与修复状态

    • Main 修复 #30862 已合入,merge commit 2b388dd1690f83e2e807d6809180336dae2a68eb;2026-10-26 核对的官方 main 为 861a2c4cb68961d8b6b01f18e0aa6ac52a3a505f,包含该修复。
    • 4.2 发布线修复 #30863 已合入,merge commit 17f4f87ea0bee9c7b6641b5c12c87e741cdd8321;核对的官方 4.2-dev 为 86a45d39df3d1f23490fcdd7328b46c5520efada,包含该修复。

    已执行的定向测试

    • 先前在独立本地 1 LOG / 1 TN / 1 CN、直连 CN 的 4.2-dev 86a45d39df3d1f23490fcdd7328b46c5520efada 服务上,用合成数据构造 correlated NOT EXISTS + 动态 LIKE,EXPLAIN 核对进入 ANTI Join。正常查询结果作为对照,未用客户端报错代替服务端退出证明。
    • 查询进入执行后分别触发 KILL QUERY、KILL CONNECTION、客户端断开:各 3/3 次观察到原执行/事务在有界时间内退出;客户端断开场景等待 4.2 现有约 30 秒检测资格后再触发。正常查询与连接恢复对照通过。
    • 定向 go test -race ./pkg/sql/colexec/loopjoin -run '^TestLoopJoinCancellation' -count=10 通过。这里仅记录定向结果,未声称完整测试套件或整套 CI 通过。

    本次 TKE 检查与未覆盖项

    • 2026-10-26 只读检查用户指定的 TKE 环境:3 LOG / 1 TN / 3 CN / 2 Proxy,CN limit 为 14 CPU / 55 GiB。运行镜像对应产品 SHA 2f8011faecaa402801288ca4e34270d8bd404a92,包含 Main 修复,但比检查时官方 Main 落后 24 个提交,也不是 4.2-dev 镜像。
    • 该环境正执行 Big Data 10Y run #40259625947 的 10 亿行用例,检查时 Regexp 用例在运行;工作流完成后会清理环境。本次没有在该环境执行 SQL 负载、KILL、断连或故障注入,不能计作 TKE 通过次数。
    • 仍未等价复验原 IDC 多 CN / Proxy、16 CPU / 55 GiB CN、原 MOI 查询负载下的取消投递、LoopJoin worker/事务清理与 CPU 回落;整套 PR CI 也未在本条记录中重新核定。

    待使用不影响运行中 CI 的隔离环境、准确版本和原规模补测后,再按最终验收格式给出结论。本条仅记录已做与未做,不关闭或改派 issue。

  7. Ariznawlll commented on Nov 6, 2026

    @Ariznawlll
    Collaborator

    测试版本

    MatrixOne 官方 main 65b721e1b93c6b9e05db2063b220e0c35916b335;本地独立 1 LogService / 1 TN / 1 CN,SQL 直连 CN。原问题发生于 4.2.6 的多 CN / Proxy 环境,本轮不将 main 上的结果等同于 4.2 发布版本验证。

    原问题验证

    两个各 30,000 行的表执行 a JOIN b ON a.s LIKE CONCAT('%',b.s,'%');每次先通过 SHOW PROCESSLIST 确认目标连接正在执行该查询,再执行取消并检查服务端状态。KILL QUERY 3/3 次均返回成功,客户端返回 1317/context canceled,客户端线程在约 0~3 ms 退出;服务端随后不再将该语句报告为活跃,管理连接仍能执行 SELECT 1。

    Happy Path 覆盖

    正常等值 JOIN 小范围对照返回 10 行计数;每次取消后管理连接执行 SELECT 1 成功,测试库最终可删除,独立实例正常停止。

    Unhappy Path 覆盖

    • 补充更接近原报告的 NOT EXISTS + 动态 LIKE 查询,同样的 KILL QUERY、KILL CONNECTION、主动断连各 3/3 次退出;断连后进程列表活动语句约 0.5~1.1 秒内消失。该查询的逻辑计划为 MARK Join,不能写成已证明原问题的 ANTI LoopJoin 执行路径。
    • KILL CONNECTION:确认查询在执行后 3/3 次取消,客户端返回 context canceled,服务端不再报告该查询活跃。
    • 主动断开 TCP:确认查询在执行后 3/3 次断开;客户端观察到连接丢失,服务端在约 0.5~1.1 秒内不再报告该查询活跃。这里另外检查了服务端状态,而不是只依据客户端断连错误。
    • 活动状态检查允许最多 5 秒等待 SHOW PROCESSLIST 刷新;本轮未独立核对内部 worker goroutine、事务对象及 CPU 曲线,不能将进程列表变化等同于这些资源全部回收。

    白盒验证

    逻辑 EXPLAIN 显示非等值 LIKE JOIN;本轮未成功取得可用的物理计划,不能断言已直接观察到 LoopJoin.scanProbeMatches。修复及此前定向 race 证据见该 issue 既有评论;本轮没有重新运行对应 Go 测试。

    回归测试

    本轮执行隔离脚本 test_30836_cancel.py、test_30836_kill_connection.py、test_30836_disconnect.py,未向 MatrixOne 主库提交测试 PR。日志中首次测试脚本将 processlist 的 conn_id 误读为 id,修正后重新执行;另一次即时状态断言未等待列表刷新,改为有界轮询后重测。两次中间尝试均重启自建实例清理,不能当作产品通过或失败证据。

    测试证据

    上述三个脚本对应 .log 各记录 3 次观察到活跃查询、操作及退出结果。查询为合成 INNER JOIN 和 correlated NOT EXISTS,均为 30,000 × 30,000 行;后者逻辑计划为 MARK Join,未复现原 ANTI LoopJoin 物理路径或实际 MOI 负载、4.2 镜像、多 CN / Proxy、JDBC server-prepared、滚动资源压力或 CPU 下降。

    测试结论

    当前 main 两种本地简化查询的 KILL QUERY、KILL CONNECTION 和 TCP 断连均各 3/3 次在有界时间退出;原 4.2 分布式工作负载、物理 LoopJoin 与事务/worker/CPU 回收尚未完整验收,保持 Open。

  8. Ariznawlll commented on Nov 18, 2026

    @Ariznawlll
    Collaborator

    QA 双分支回归交付完成(本 issue 的可验证范围)。

    已交付

    验证证据

    • main @ 517e1695388cbaf1135238d5ab0c19a4556fb551、4.2-dev @ 72c43e9305d8355c940075e414f30eaf2e4112a6
    • motr --repeat 2:双分支 record 2/2 PASS、verify 2/2 PASS;SQL 取消场景客户端边界均为 1317 context canceled,语句/事务/LoopJoin worker 全部移除。

    保持 OPEN 的原因:原 issue 标题含 4.2.6 高 CN CPU + 多 CN/Proxy 拓扑与 MOI 负载,本交付未覆盖该拓扑(单 CN 本地实例验证),该部分待后续拓扑化验收后关闭。

  9. Ariznawlll commented on Dec 1, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。 补齐 4.2-dev 的真实 Proxy / 双 CN / 三 LogService 拓扑,三轮物理 LoopJoin 取消、事务/执行线程清理和 CPU 回落检查通过;七个根测试各 race 三轮通过。最新 4.2-dev 的独立 Linux CI 又完整执行三轮并通过,证据见下。

    关键证据

    1. 分支、版本、部署

      • 修复 #30863 合入 4.2-dev,merge SHA 17f4f87ea0bee9c7b6641b5c12c87e741cdd8321;源码 ancestry 已核对。
      • 本次运行 fa22bd6c9fcb8603779f686bb5e568c6f7deec5e,128 隔离目录,未经 QA 修改的 MO 服务二进制。两个 CN 与 Proxy 三个 SQL 入口分别查询 git_version(),均等于该完整 SHA。
      • 实际 3 个 voting LogService、1 TN、2 CN(TP/AP)、1 Proxy,七个独立进程;核对 SHOW LOGSERVICE REPLICAS 和 SHOW BACKEND SERVERS,而不是只数启动命令。全部在同一 Linux 主机,不宣称跨物理机或 Kubernetes 原现场验收。
    2. 原始问题路径与正常对照

      • 从 Proxy 连接执行 correlated NOT EXISTS + 动态 LIKE 的合成查询,2048×8192 行,字符串包含重复较长文本。每次先通过 session 记录锁定 connection/statement/txn,再从两个 CN 的 goroutine profile 观察 loopjoin.(*container).scanProbeMatches 与 LoopJoin.Call,确认已进入昂贵执行路径后才取消。
      • 正常小规模对照为 32×64 行;物理计划是 LoopJoin,精确结果为 id=17…32;不拿普通等值 HashJoin 成功替代本路径。
      • 同一拓扑每轮分别执行 KILL QUERY、KILL CONNECTION、独立客户端进程终止造成真实 TCP 断连,三轮共九次取消。断连场景保留产品的 30 秒检测 grace,单调时钟及 SQL query_start 均过门槛且 LoopJoin 仍活跃后才关闭 transport,未修改前端检测政策。
    3. 实际输出与清理证据

    round 1: exit=0
    round 2: exit=0
    round 3: exit=0
    receipt.status = passed
    

    每轮三种入口均核对:不返回正常查询结果;KILL 客户端收到本分支的 context canceled;原 statement/txn 消失;两个 CN 不再存在该 LoopJoin 执行 worker;连接生命周期符合 QUERY/CONNECTION 的差异;后续 SQL 成功。断连另外按 statement/txn 与 Proxy 日志关联 cancel、rollback、routine cleanup、Proxy close,不只凭客户端异常或 processlist 消失判断。

    PASS: disconnect: original transaction is removed
    PASS: disconnect: executing LoopJoin worker is removed
    PASS: disconnect: connection lifecycle matches the cancellation entrypoint
    PASS: disconnect: subsequent SQL remains healthy
    CANCEL_EVIDENCE ... workers_after 0
    SUMMARY: all assertions passed
    

    每轮独立测试库均删除;最后七个服务退出码全部为 0,未触发超时强杀。第一次尝试第二轮碰到多个隔离服务同时 SIGTERM,已作为环境中断保留,不计成功或产品失败;这里的三轮是之后完整重跑的结果。

    1. CPU 观察

    对 fixture 两个 CN 的 /proc/PID/stat 分别取计数并求和,每段采样 3 秒;单位是 CPU 秒/墙钟秒(核),只统计自己启动的两个 CN,不使用整机 CPU。

    轮次 入口 执行时核数 取消并清理后核数
    1 KILL QUERY 1.050 0.047
    1 KILL CONNECTION 1.060 0.043
    1 TCP 断连 1.047 0.047
    2 KILL QUERY 1.053 0.050
    2 KILL CONNECTION 1.063 0.047
    2 TCP 断连 1.060 0.050
    3 KILL QUERY 1.060 0.057
    3 KILL CONNECTION 1.060 0.050
    3 TCP 断连 1.077 0.060

    各次取消前空闲基线为 0.053–0.090 核。取消后均回到相近基线,结合 worker/txn 归零,支持“执行真正退出”的判断。这里没有复刻原现场 16 核饱和或五小时业务积压,也不宣称客户 SQL 的正常执行性能有所提升。

    1. 白盒与回归
      • 同一 4.2-dev SHA 的四个 LoopJoin 取消根测试、三个 LIKE 取消根测试各 race 重复三次(21/21),覆盖 probe 中取消、条件窗口释放、预先取消、Reset 复用、regexp/fast-path 批量取消和未执行行保留,全部通过且无 race 报告
      • CPU 观察追加现有 MOTR 4.2-dev PR #399。真实拓扑脚本已接入 qa-32855-42-daily.yml,使用 job 实际检出的 4.2-dev 二进制及完整 SHA,完整三轮并保存 receipt/round logs。原有 broader acceptance job 仍复用同一脚本。
      • 离线测试 970/970 通过;本地拓扑三轮通过。最新专项 CI 整个 job success,MOTR 提交 b063c938a824333006f7b48dbe01bc237e2df1d2。
      • 已下载并独立核对约 5 KB 验收附件:CI 实际 MO 版本为 167a1a91999f43146393995286b8237a0f6e0942,三轮均 exit=0、receipt.status=passed,七个服务均 exit=0 且没有 forced_cleanup。这个版本比本地基线增加一个 IVF NaN 主键修复提交,新的真实 SQL 拓扑也已重新覆盖。
      • CI 九次取消前活动 CPU 1.046–1.092 核,清理后 0.070–0.107 核;正常基线 0.067–0.080 核。三次断连均记录单调时钟等待超过 31 秒、SQL age=31 秒后注入;三轮 worker/statement/txn 清理断言全部成功。没有只凭 Actions 绿色标记或客户端断连判定通过。
      • 没有主库测试 PR;按目标分支交付,不把 4.2 结果当作 main 实测。
      • 每日调度依赖本 PR 合入;未合入前不声称新用例每天已经执行。

    待解决点

    本 Issue 的受控故障语义验收、定向 race 和最新 4.2-dev CI 已完成;MOTR PR 等待合入,每日新步骤须在合入后生效。本轮针对实际 LoopJoin/LIKE 取消交付、执行与事务资源退出、Proxy 路径和 CPU 不继续占用;原始客户数据、跨物理机以及五小时业务负载没有复刻,不据此作业务性能承诺。

    最终结论:测试通过。4.2-dev 本地及最新 CI 的双 CN / Proxy 三轮取消均完成,原先取消后执行持续不退出的问题未复现;物理执行线程、事务清理、CPU 回落、正常查询及进程退出均通过,定向 race 21/21 通过。回归已追加现有 MOTR 4.2-dev PR #399;本轮未确认该范围内的产品失败,不外推为 main 或其他业务负载已验收。

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions