Skip to content

[Bug]: Full TPCC suite accumulates long-lived row locks and cascades into lock wait timeouts #29429

Closed

Description

@daviszhen

Summary

在 129 单机的完整 TPCC suite 中,MatrixOne 在没有 OOM、没有进程重启的情况下出现长时间持有行锁和事务完成停滞,随后级联产生 1205 Lock wait timeout、context deadline exceeded,最终多个 TPCC case 被 workflow 以 exit 124 终止。

本 issue 关注的是“事务未及时完成/释放锁导致的级联失败”,与 #26182 中的高并发锁等待现象相关,但本次故障在较小的 10W/100T 阶段已经开始,并且初始故障发生时没有内存上限压力。

Reproduction

执行顺序为 TPCC load 10W、10W/10T、10W/100T、100W/100T、100W/1000T、1000W/1000T。

Actual result

Case Result Evidence
10W/10T Functional PASS, but tpmC=81.88 历史基线中位数为 7464.95,性能检查要求重试
10W/100T Verify FAIL 3 次 1205 Lock wait timeout;一致性校验本身通过
100W/100T exit 124 13 次 1205;达到时间限制后一直等待活动事务结束
100W/1000T exit 124 72 次 1205、1913 次 20101 context deadline exceeded
1000W/1000T exit 124 9 次 1205、2149 次 20101 context deadline exceeded

100W/100T 的 jTPCC 日志先记录:

The time limit has been reached.
Waiting for all active transactions to end...

随后 case 达到 workflow 的 15 分钟硬超时,返回 124。

Relevant logs

MatrixOne 服务日志中,在第一个 TPCC 1205 之前已经出现:

cn-service.lockservice: wait too long
wait: 1m+
lock: Exclusive(row): holder(...), waiters(...)

时间线(Asia/Shanghai):

  • 23:51:52:开始反复出现 iscp transaction finish timeout
  • 23:51:57:lockservice 首次报告行锁等待超过 1 分钟
  • 23:52:31:服务端首次记录 TPCC 1205,语句为 bmsql_district ... FOR UPDATE
  • 23:52:32:客户端首次记录 TPCC 1205

这表明失败不是单个事务偶发重试,而是存在持锁事务未及时完成、后续请求排队的迹象。iscp transaction finish timeout 与故障时间相关,但 #29392 已指出该类日志可能存在构造阶段误报,因此还需要独立确认其与锁释放的因果关系。

Memory and OOM evidence

本次没有发现硬 OOM:

  • memory_failcnt=0
  • Docker OOMKilled=false
  • MatrixOne 没有重启
  • 主机 oom_kill 保持 34 -> 34
  • 初次出现锁等待时,lane aggregate cgroup 内存约为 5–8 GiB

后续 1000W 阶段 lane aggregate cgroup 峰值约 84.62 GiB,但这发生在锁等待问题已经出现之后,不能作为初始根因。

Initial assessment

当前最可能的故障链路是:

事务完成/锁释放停滞
        -> 行锁等待超过 1 分钟
        -> TPCC 返回 1205
        -> 活动事务无法及时结束
        -> 后续 case 出现 context deadline exceeded
        -> workflow 以 exit 124 终止

目前 artifact 中没有记录完整的持锁事务调用栈,因此尚不能确定具体是事务提交、锁服务、ISCP transaction finish,还是其他后台任务阻塞了事务完成。

Expected result

完整 TPCC suite 应在所有阶段完成,事务错误为 0,活动事务能够在 case 到达时间限制后正常退出,并且不应持续出现超过 1 分钟的行锁等待。

Suggested investigation

  1. 在首次 lockservice wait too long 时采集持锁事务的状态、SQL、开始时间和提交/回滚路径。
  2. 关联 iscp transaction finish timeout 与具体事务 ID,确认它是否阻塞锁释放,或只是误报日志。
  3. 在每个 TPCC case 结束时检查是否仍有 active transaction/lock waiter,避免后续 case 继承前序状态。
  4. 使用全新 MatrixOne 实例分别运行 10W/100T 和完整 suite,区分单 case 问题与前序状态累积。
  5. 增加完整 TPCC suite 的回归测试,覆盖零 OOM 但事务锁长期不释放的场景。

Related issues

Activity

  1. daviszhen commented on Sep 28, 2026

    @daviszhen
    ContributorAuthor

    补充最近 3 天 mo-auto-test main 分支中标题为 129 Family · full · all · full · main 的回归结果。

    结论:最近 3 次运行中有 1 次明确出现 TPCC 锁等待问题,另外 2 次未复现,当前表现为间歇性问题。

    Run TPCC 结果 锁问题
    36329945107(TPCC report) 失败 10W/100T、100W/100T、100W/1000T、1000W/1000T 均出现 Lock wait timeout;后 3 个 case 以 exit 124 超时
    36252336114(TPCC report) 成功 客户端和服务端均未发现锁等待超时,全部 TPCC case/verify 通过
    36155105197(TPCC report) 成功 客户端和服务端均未发现锁等待超时,全部 TPCC case/verify 通过

    Run 36329945107 的详细证据:

    • 服务端约有 192 条 Lock wait timeout exceeded、151 条 wait too long。
    • 10W/10T 的 tpmC 只有 81.88;正常的两次运行分别为 7464.95 和 7456.90。
    • 10W/100T、100W/100T、100W/1000T、1000W/1000T 的客户端日志分别出现 3、13、71、9 条锁等待超时。
    • 100W/100T、100W/1000T、1000W/1000T 最终均因长时间等待以 exit 124 退出。

    Run 36252336114 和 36155105197 的服务日志中虽然存在 iscp transaction finish timeout,但没有 lockservice wait too long 或 Lock wait timeout exceeded,且 TPCC 全量验证成功,因此不能仅凭这些日志判定为 TPCC 锁问题。

    另外,三次 GitHub 回归任务的整体状态均为 failure,但后两次的 TPCC job 均成功,整体失败来自其他测试族或检查。

  2. LeftHandCold commented on Sep 28, 2026

    @LeftHandCold
    Collaborator

    Root-cause update: confirmed performance regression introduced by #28851

    The investigation now has a deterministic adjacent-commit reproduction of a prepared numeric-primary-key storage-filter regression, in addition to the TPCC symptoms originally reported here. A TKE run reproduces the severe throughput collapse and also exposes Sysbench failures through the same affected point-lookup path.

    This is not an OOM explanation, a generic claim that high concurrency is unsupported, or an attribution based only on commit timing.

    Affected version and introducing commit

    • Introducing PR: fix: align date compatibility semantics #28851, fix: align date compatibility semantics.
    • Introducing commit: a99db843c7b4630a86883addc9424433d93fc2d2.
    • Direct parent: 1575e70c3db676d3ed00abc080aadc029b0e1435.
    • Additional affected version: d99187d7b3bfda8744088b3ae8cf16739b690aa0.
    • TKE reproduction, run 36409954461 / TP job 108895394411.
    • Namespace: mo-main-family-36409954461-1; TP CN: nightly-regression-dis-tp-cn-q5ld4.
    • Topology: 1 TP + 2 AP CNs. Each CN has 55 GiB memory and 16 GiB MemCache; TN has 32 GiB memory and 5 GiB MemCache.
    • TPCC uses server-side prepared statements (useServerPrepStmts=true).

    The original 129 reproduction in this issue also used the introducing commit a99db843c7. The detailed runtime chain below was independently collected from TKE; it is not presented as a reconstruction of every transaction from the original 129 run.

    The code defect

    For a normal parameterized integer-key predicate such as WHERE id = ?, the prepared plan contains an implicit string-shaped-parameter-to-integer CAST. The new statement-diagnostic classification treats this CAST as potentially diagnostic and removes the containing predicate from storage filters even when the current bound value is a valid integer.

    The original SQL predicate remains in the upper-level filter, so this is a selectivity/performance regression, not evidence that the WHERE condition stops being enforced.

    Relevant source at the affected job SHA:

    1. compileTableScanDataSource calls filterScanStorageExprs before folding the current execution's parameters. Both reader filters and block filters go through this screening.
    2. filterScanStorageExprs now excludes constant/statement-invariant diagnostic expressions.
    3. containsStatementInvariantFilterDiagnostic returns true for a potentially diagnostic parameter without evaluating its valid bound value to establish safety.
    4. MayDiagnoseStatementParameter includes implicit string-to-numeric CASTs.

    The join-specific diagnostic-free proof does not cover an ordinary single-table point lookup. Normal numeric parameter executions can retain the prepared plan; they do not necessarily replace the CAST with a literal before this check.

    Deterministic parent/commit/current verification

    An isolated local worktree was used. Production implementation was not changed or stubbed. The harness exercises the production SQL parser, BuildPlan, storage-filter selection, and parameter folding.

    The parser/planner probes are:

    SELECT p_name FROM tpch.part WHERE p_partkey = 7;
    PREPARE s FROM SELECT p_name FROM tpch.part WHERE p_partkey = ?;

    tpch.part here is the existing NewMockCompilerContext table, not a separately loaded benchmark dataset. The prepared query is bound to valid value 7 in the process parameter vector. A second expression-level probe independently verifies that the same CAST(?) successfully folds to integer 7.

    Check Parent 1575e70c3d #28851 a99db843c7 Job SHA d99187d7b3
    Literal integer-key predicate Retained 1/1, PASS Retained 1/1, PASS Retained 1/1, PASS
    Actual prepared SQL's scan predicate Retained 1/1, PASS Dropped 0/1, FAIL Dropped 0/1, FAIL
    Valid numeric-parameter expression Retained 1/1, PASS Dropped 0/1, FAIL Dropped 0/1, FAIL
    Independently folding parameter 7 Successful Successful Successful

    The job SHA was additionally tested with -count=5: both parameterized assertions failed on all five executions, while the literal control passed all five times. These are intentional invariant-check failures demonstrating the defect, not test compilation or setup failures.

    This pins introduction of the storage-filter defect to the adjacent transition 1575e70c3d -> a99db843c7. It is not a claim that a full TKE TPCC suite was rerun on the parent or that a fix has already passed acceptance.

    Historical throughput: the previous nightly was already affected

    TPCC warehouses / terminals Earlier b1b68925d7 Previous nightly 5a96035fc7 Current d99187d7b3 Current transaction errors
    10 / 10 5919.79 92.25 94.84 0
    10 / 100 9876.64 94.67 95.09 0
    100 / 100 11132.10 6.97 7.07 7
    100 / 1000 10236.35 6.50 7.35 1151
    1000 / 1000 4628.21 0.00 0.02 2602

    Values are tpmC. Sources: earlier run 36250512349, previous run 36335119263, and the current TKE job above.

    Sysbench point_select, 1000 clients, 10 tables of 10 million rows each:

    Metric Earlier b1b68925d7 Current d99187d7b3
    TPS 18046 13
    Average latency 55.38 ms 78555.76 ms
    Maximum latency 379 ms 118074 ms

    The previous nightly already contains #28851 and has almost the same collapse. Therefore the additional dual-AP-ingress workflow change in the current manual run cannot explain the introduction of this regression.

    Runtime evidence: scans, lock holding, and admission

    All timestamps in this section are UTC on 2026-09-28; add eight hours for CST.

    Scan amplification

    • At 10:57, during only 10 warehouses / 10 terminals, TP CN txn.table.ranges.log repeatedly reports bmsql_stock, exprs="", blocks=125.
    • At 11:16:22.704498, a 100-warehouse stock scan reports exprs="", blocks=1230.
    • At 12:46, during Sysbench point_select, multiple sbtest tables repeatedly report exprs="", blocks=1231.

    The exprs field records the storage BlockFilters, not the absence of an SQL WHERE clause. Together with the reproducible reader-filter loss and CPU stack, this establishes the selective-query-to-large-scan failure mechanism.

    Same-holder lock-wait chain

    Holder transaction: 0b2bee4edc43841018d97698c30799a5.

    UTC Observation
    11:16:22.704498 Holder starts stock scan with 1230 blocks and empty storage filters
    11:17:41.230641 Waiter 0b2bee4edc43841018d97698c3079a32 has waited about 61.975 seconds for this holder
    11:17:43.447673 Holder statement 01a0e7ba-ee2f-72eb-9698-c2c9940f7e27 reports Exec.Run duration 80.744 seconds
    11:18:21.853048 A subsequent holder execution takes another 38.260 seconds
    11:18:39.257264 The waiter's district UPDATE returns lock-wait timeout
    11:18:57.358526 Another holder execution takes 35.424 seconds

    The waiter executes UPDATE bmsql_district SET d_ytd=d_ytd+? WHERE d_w_id=? AND d_id=?, with parameters 4665.7, 57, 4.

    This is evidence of very slow work while holding locks, rather than proof of a lockservice unlock leak or a commit deadlock.

    CPU profile

    TP CN CPU profile, 10:57-11:02:

    • runtime.memmove: 29.96% self.
    • Vector.unionBatchContiguousVarlenRange: 19.21% self.
    • vector.shrinkFixed: 13.91% self.
    • ConstructRowidColumnTo: 3.77% self.

    The dominant copy stack goes through TableScan -> reader.Read -> BlockDataRead -> materializeBlockData -> LoadColumnsDataInto -> CopyCachedVectorAll -> UnionBatch, followed by the upper-level Filter. Cached data still incurs this repeated materialization/filtering cost.

    Sysbench connection/admission failures

    • At 12:53:19, 12:53:30, and 12:53:41, Proxy reports approximately 10-second backend handshake timeout, stage read-auth-response, against the TP CN.
    • Proxy then reports all candidate CN servers are temporarily unhealthy, candidate-count=1; read_only starts failing with 20508 at 12:54:37. This is the matching TP candidate being temporarily unavailable, not evidence that all AP CNs are also unavailable.
    • At 13:11-13:12 and 13:15-13:16, TP CN transaction queue metrics show approximately 160 active / 840 wait-active transactions; the sampled commit queue is zero.
    • Starting at 13:12:28, CN reports transaction error: wait active; update_index/update_non_index fail with context deadline exceeded / createTxnOpUnsafe.
    • The targeted 12:40-13:25 query did not find transaction-client pause/resume transitions. This should not be automatically attributed to the separate logtail-reconnection/admission-pause issue [Bug]: catalog logtail recovery abandons slow forced-flush subscriptions, pausing CN transactions for 185s #29275.

    Impact and remaining boundaries

    • This is a Main performance regression with availability consequences, affecting common prepared numeric-key query paths, not only date SQL.
    • No pod restarts or OOM evidence were found in the observation window. The 10-warehouse / 10-terminal case was already severely degraded, before high concurrency could be the sole explanation.
    • All five current TPCC consistency checks passed. No durable data corruption was observed; these checks do not prove every database invariant.
    • Concurrent AP work can amplify resource contention, but it does not explain the deterministic loss of a valid storage predicate.
    • The entire large-job failure count has not been individually reconstructed, and no full TKE revert/fix acceptance run was performed.
    • A fix must recover selectivity for valid bound parameters without discarding the warning/error, empty-input, or short-circuit semantics that motivated the diagnostic guard. Simply increasing timeouts or transaction admission limits does not address this defect.

    No production code or cluster configuration was changed during this investigation.

  3. added
    severity/s0
    and removed on Sep 28, 2026
  4. added and removed
    severity/s0
    on Sep 28, 2026
  5. daviszhen commented on Sep 29, 2026

    @daviszhen
    ContributorAuthor

    Lock wait timeout 二分结论

    已使用 129 TPCC workflow,固定运行以下 4 个场景:tpcc10.10、tpcc10.100、tpcc100.100、tpcc100.1000。

    二分边界

    • 正常 commit:1575e70c3db676d3ed00abc080aadc029b0e1435

      • Run 36517965412
      • 四个场景及校验全部通过
      • Transaction Error = 0
      • 未发现 Lock wait timeout、ErrorCode 1205 或 wait too long
    • 异常 commit:a99db843c7b4630a86883addc9424433d93fc2d2

      • Run 36521626546
      • tpcc10.100 出现 2 次 ErrorCode 1205: Lock wait timeout exceeded,均为 TT_PAYMENT
      • Transaction Error = 2,校验失败;后续 tpcc100.* 未继续执行
      • 服务端同时出现 wait too long 和 iscp transaction finish timeout
      • 该 commit 在 Run 36329945107 中也出现过同类锁等待失败

    结论

    1575e70c... 与 a99db843... 为相邻提交,因此当前二分已定位到:

    a99db843c7b4630a86883addc9424433d93fc2d2 是首个出现 Lock wait timeout 的异常 commit。

    该提交标题为 fix: align date compatibility semantics (#28851)。测试期间内存峰值约 8.9 GiB,memory_failcnt=0,主机 OOM 计数未增加,因此本次失败不是内存压力导致。以上结论是回归定位证据,具体代码根因仍需进一步检查该提交的变更。

  6. added a commit that references this issue on Sep 29, 2026
    a36da7f
  7. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • 修复 PR:#29462
    • 修复 merge commit:a36da7f72d78030d8822ac310a9d20089db4c90f
    • 129 完整 TPCC 验证 commit:32f54981401fd3888702f2dab8702d2e62c6997a
    • 当前 main:d59cc02ef6ca68f340c9570e56f7eb71d90e42e7
    • 部署方式:129 单机,Slot A,TPCC sibling-free confirmation;BenchmarkSQL 使用服务端 prepared statement
    • 测试日期:2026-10-02

    已核对 Git 提交关系:修复 commit 和验证 commit 均为当前 main 的祖先,当前 main 已包含该修复。

    原问题验证

    原问题已定位到 #28851 的 commit a99db843c7b4630a86883addc9424433d93fc2d2。普通 prepared 数值主键条件的 storage filter 被移除,点查/点更新退化为大范围扫描;事务执行时间和持锁时间被放大后,级联产生 1205 Lock wait timeout、context deadline exceeded,最终多个 TPCC case 被外层超时以 exit 124 终止。

    修复 #29462 在参数绑定和优化阶段恢复了 prepared 数值条件的选择性,并保留转换诊断语义。修复合入后,使用完整 TPCC suite 进行了两轮独立验证,均执行以下五个场景:

    1. 10W / 10 terminals
    2. 10W / 100 terminals
    3. 100W / 100 terminals
    4. 100W / 1000 terminals
    5. 1000W / 1000 terminals

    两轮均完成全部负载与一致性校验,没有再次出现原问题的长时间持锁、case 无法收尾或 workflow 超时终止。

    正常路径覆盖

    场景 Run 36885694565 tpmC Run 36893212245 tpmC 事务错误 一致性校验
    10W / 10T 3164.90 3054.63 0 / 0 PASS / PASS
    10W / 100T 8636.90 8850.23 0 / 0 PASS / PASS
    100W / 100T 9262.40 9224.55 0 / 0 PASS / PASS
    100W / 1000T 8588.10 8536.45 0 / 0 PASS / PASS
    1000W / 1000T 6215.63 6307.47 0 / 0 PASS / PASS
    • 两轮均生成并写入 5 份有效 TPCC 性能报告,未跳过失败或无效报告。
    • 所有场景均在正常预算内结束,没有 exit 124。
    • 两轮的资源/清理门禁均通过,没有因 OOM 或 MatrixOne 重启形成假通过。

    异常症状核对

    对两轮完整 Job 日志检查以下原问题特征:

    • Lock wait timeout:0
    • wait too long:0
    • 非零 Transaction Error:0
    • context deadline exceeded:0
    • exit 124:0

    原失败 Run 36329945107 中,10W/100T 之后出现 1205,后续三个大场景超时退出;修复后的两轮中,相同场景全部完成且事务错误为 0,说明原来的“扫描放大 → 长持锁 → 锁等待 → active transaction 无法结束 → 超时终止”链路未再复现。

    白盒验证

    修复 PR 增加了 test/distributed/cases/prepare/issue_29429_prepared_filter.sql 及对应结果文件,覆盖 prepared 参数绑定、数值主键过滤和重复执行。PR 验证记录还包括:

    • 原 issue 用例 61/61 通过;相邻 vector prepared-range 用例 64/64 通过。
    • 两个 CN 分别重复执行,总计 500/500 通过。
    • frontend、plan、function、compile 等相关 package 测试通过。
    • prepared cache replacement、retry proof、AP plan reuse、reader/remote filter ownership 的 focused race 测试通过。
    • 三组 parent/current 性能对照共六次运行均为零事务错误;修复版本平均达到直接父提交的 102.59%,恢复了该缺陷对应的 prepared 执行性能。

    回归测试

    范围说明

    当前另有独立问题 #29564:#29527 引入 prepared stats admission 重复重建计划,导致 TPCC 吞吐下降。该问题的五个场景可以完成、事务错误为 0,不会复现本 issue 的 1205、长持锁和 exit 124 链路,因此继续由 #29564 单独跟踪,不作为 #29429 的复现。

    测试证据

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions