Skip to content

[Bug]: CN loss can leave lock retry requests blocked ~150s past a 10s backend budget #32834

Open

Description

@Ariznawlll

Description

In the long-running 4.2-dev distributed Chaos environment, requests already in flight during a single-CN pod kill returned 20702: lock table bind changed after approximately 150 seconds. The server recorded a 10-second backend lock retry budget and logged that the budget was exhausted about 140 seconds after its own deadline. Other requests had resumed making progress during the same period.

This report records an observed production-like test incident, not a controlled reproduction. The causal explanation below is a strong hypothesis, not yet a proven per-transaction root cause.

Environment

  • Branch: 4.2-dev; observed image tag: commit-b97995b. The tag resolves to source commit b97995b007051b28d0f98bffc6f210da0aa9b866, but the full runtime SHA was not independently verified from the running binary.
  • IDC distributed test: 2 CN, 1 DN, 3 LogService and 1 Proxy; mo-chaos-4-2-dev-fca65de-202608290941. Existing long-running setup: run 33227006312.
  • Workload: concurrent Sysbench inserts through the existing test harness. Times below are 2026-11-17, UTC+8. The preceding 4.2-dev image update ended at 01:04:20, outside both observed windows.

Observed sequence

  1. At 06:11:31 a CN PodChaos fault started; the fault resource was removed at 06:12:02. Seven logged Sysbench requests initiated around 06:11:33 returned 20702 around 06:14:03, approximately 150 seconds later.
  2. In a separate rotation at 09:42:20 a CN PodChaos fault started; the fault resource was removed at 09:42:51. Seven Sysbench requests initiated during that fault returned the same error at 09:45:16–09:45:18, approximately 150–151 seconds after their recorded request times.
  3. For one affected transaction, the surviving CN logged remote lock connection failures from 09:42:48; retry-budget=10s and retry-deadline=09:42:58.432 were recorded when the budget was reported exhausted at 09:45:18.462, about 140 seconds after that deadline.

The fault resource's removal time is not itself proof that all cluster components had recovered. Sysbench throughput resumed by the 09:43:27 sample, while the older requests remained outstanding. The 09:43 TPCC consistency checker failure was a SQL exception (backend connection closed), not a demonstrated data mismatch; later TPCC consistency checks succeeded.

Expected behavior

A backend-unavailability retry budget should not be silently bypassed by an in-flight attempt for approximately two additional minutes. Affected requests should terminate or otherwise be bounded according to the intended backend retry and cancellation policy, while normal lock waits, error semantics, transaction cleanup and unrelated requests remain correct.

Code analysis — hypothesis, not yet confirmed root cause

  • In incident-version lock_op.go, the backend retry budget is 10 seconds. The retry loop checks the retry state after a lock call returns; the backend retry deadline is not visibly propagated as the deadline of that in-flight call.
  • The remote-lock RPC context uses the lock-wait deadline plus 30 seconds. The incident-version default lock wait is 120 seconds. A later read-only check found the current global value and a newly created admin session both at 120 seconds; the actual incident sessions' values were not verified. The observed 150 seconds is consistent with 120 + 30, but numerical agreement alone is not proof.
  • A Pyroscope aggregate block profile, for the affected surviving CN and 09:43–09:45 window, included lockWithRetry → lockservice.(*service).Lock → remoteLockTable.lock → morpc.(*client).Send → waitBackendChange → waitBackendCreateCompletion. This is a process-wide aggregate, not a transaction-specific goroutine stack and not proof that this path accounts for the full gap in the cited transaction.
  • Hypothesis: once a backend error establishes the 10-second deadline, an in-flight remote lock/backend creation wait can outlive that deadline because it uses a different longer context. Confirm the actual blocked frame, exact cancellation/timeout behavior, and whether this is intended before attributing the root cause conclusively.

Stability and controls

  • Two separate natural Chaos rotations produced the described timing pattern; the counts are observed log records, not 2/2 controlled reproductions.
  • No isolated reproducer, no-fault control, latest-main runtime test, or data-atomicity verification was performed. The lock_op.go file content was identical in the observed source revision and the then-current 4.2-dev head fc6c7fee10f14591dd60fd6b35464b6361d8ab42; other dependencies may differ and current behavior is unverified.
  • Need a controlled 2-CN fault test and passing no-fault control, repeated on latest official main and 4.2-dev, retaining the in-flight call stack and checking cleanup, errors and transaction outcomes.

Evidence

Related

  • #31184: 20702 after CN loss for catalog DDL; a shared root cause is unproven.
  • #26125: historical, closed report of hung statements following a roll; distinct observation and unproven relationship.
  • #27523: surviving CN retries a killed CN's pipeline endpoint; this report observes a lockservice path and does not assert the same failure.

Activity

  1. added this to the MO-202611 milestone on Nov 17, 2026
  2. added
    kind/bug
    on Nov 17, 2026
  3. added theissue type on Nov 17, 2026
  4. self-assigned this
    on Nov 17, 2026
  5. XuPeng-SH commented on Nov 17, 2026

    @XuPeng-SH
    Contributor

    QA 交接补充(不代表验收通过)

    PR #32843 已于 2026-11-17 07:47:43 UTC 合入 4.2-dev,merge SHA 2cf82017d5b5488cf68c15c3b15cf1abf56084fc,head 77c345bb85a0eead3f924b97b8e4c053b03d7c7d。本 issue 已由 @Ariznawlll 负责,仅补交接证据,保持 open,不变更负责人。

    修复将已有 lock retry deadline 传入 backend 选择、连接创建等待、重试退避及 allocator bind refresh;保留健康 backend 上正常 lock-request context。它修复已演示的 backend-wait 预算缺口,尚未证明是原 Chaos 事件全部约 150 秒等待的根因。

    现有证据(本巡检未本地测试):

    • 作者在 4.2-dev@fc6c7fee10f1 用 mock 复现旧实现等到 1 秒外层 deadline、未遵守 50 ms backend budget;修改后 MORPC/lockservice/lockop 专项正常各 10 次、race 各 3 次及完整 lockop 包通过。快进至 e8fd84b 后再通过三个包专项测试,未跑完整 MORPC 套件。
    • 审查独立 exact context-helper probe normal/race 及 100 次重复通过;依赖下载超时导致未完成本地三个包测试,不能把 helper 当完整服务验证。
    • 审查 CI 快照及最终队列有成功记录,但不能据此断言原现场故障、具体事务原子性或所有 race 已覆盖。

    QA 建议在受控 2-CN 故障恢复下验证 backend-unavailability budget,并以健康 backend 对照确认普通锁等待不被缩短。捕获事务级阻塞栈、预算时间和最终错误,检查取消/清理/原子性/后续请求恢复。原证据为自然 Chaos 轮转及进程聚合 profile,不是事务级因果证明;不保证所有 post-dispatch wait 受硬预算约束,也不表示 main 或其他版本已验收。

  6. Ariznawlll commented on Nov 20, 2026

    @Ariznawlll
    CollaboratorAuthor

    QA 阶段性进展(2026-11-20,仅精确白盒通过,尚未闭环)

    针对 #32843 已合入 4.2-dev 的 backend 选择、连接等待、重试退避及 allocator bind refresh 预算传递,现有 MORPC / lockservice / lockop 的 12 个精确测试已连续三轮通过。这些测试证明所选取的 context/deadline 路径,不等于原始 CN 丢失场景已恢复。

    尚未在受控双 CN Chaos 中复测原约 150 秒等待;事务级阻塞栈、实际预算耗时、最终错误、取消/清理、事务原子性及后续请求恢复仍缺真实证据。健康 backend 的正常锁等待不被提前截断也需保留对照。

    因此目前只记录局部白盒通过,不宣布原问题修复或性能恢复,不关闭 issue。生产 Chaos 的完整根因与 main/其他版本适用范围不由本次局部测试外推。

  7. Ariznawlll commented on Nov 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    未完成验收。此前本地证据及本轮 Linux CI 的真实 CN 故障、恢复后数据核对、底层预算测试均通过。2026-11-30 已补齐 CI,新增证据见下;原始长期 Sysbench/Chaos 负载仍未完成,因此本次不关闭,不转派。

    关键证据

    版本与实际环境

    • 本次固定的官方 4.2-dev:ea874f3f23cb14f2856d092c87d3c80cba117a97,包含修复 [4.2-dev] fix: bound lock backend retry waits #32843(2cf82017d5b5488cf68c15c3b15cf1abf56084fc)。不以 main 的结果代替 4.2-dev。
    • macOS 本地隔离环境:2 个独立 CN 进程、1 TN、3 个 voting LogService、1 Proxy,共 7 个独立服务进程。三个 SQL 入口均核对 git_version() 完整 SHA;实际读取 SHOW LOGSERVICE REPLICAS 核对三个投票副本。
    • 使用未经 QA 修改的服务二进制。实际向夹具持有 PID 的 CN2 发送 SIGKILL,不是模拟 RPC 报错,也不是优雅 Close;不涉及共享环境或其他实例。

    复现步骤与检查点

    1. 创建独立 A、B 两张表,初值分别为 A(1,10)、B(1,20)。CN2 开事务更新 B 为 30 而不提交;CN1 开事务更新 A 为 11,再执行更新 B 为 21,使其阻塞。
    2. 从 mo_locks 确认 B 的真实持锁 CN/事务,并确认更新请求仍阻塞后才注入故障。健康对照先等待超过 12 秒,再回滚持锁事务,确认阻塞更新正常完成,不能因为 10 秒 backend 预算误杀正常锁等待。
    3. 重新建立上述持锁/等待状态,真实 SIGKILL 持锁 CN2。记录在途 UPDATE 返回时间和完整错误类别;源事务回滚。
    4. 保持 CN2 关闭,再从新事务先改 A、后访问 B。记录访问失联 owner 的错误,随后回滚,核对没有部分提交。
    5. 用相同二进制、配置和数据目录重新启动 CN2;验证 SQL ready 和版本后,再有上限地等待实际写操作恢复。将正常写入 B=22 提交,从两 CN 与 Proxy 读取;恢复前回滚数据应为 A=10/B=20,正常提交后应为 A=10/B=22。
    6. 停止本轮自建服务,核对除故障注入的 CN2 为预期 -9 外,其余服务和重启的 CN2 均正常退出。

    三轮正式 MOTR 脚本执行结果

    轮次 健康锁等待后成功 kill 后在途请求返回 owner 缺失时新请求返回 重启后实际写就绪 数据与清理
    1 12.2146 s 4.667 ms 1.911 ms 0.220 s 通过
    2 12.0141 s 13.372 ms 1.679 ms 0.929 s 通过
    3 12.2187 s 6.660 ms 11.237 ms 0.934 s 通过

    故障时实际错误:

    20505 cannot connect to backend: EOF
    20505 cannot connect to backend: dial tcp4 ...: connect: connection refused
    

    重启后第 2、3 轮第一次写入各出现一次 20702 lock table bind changed;使用新连接/新事务重试后恢复,已计入上表写就绪时间,没有隐去瞬态错误。所有轮次均断言回滚没有保留 A=11 或 B=21,恢复后的新提交能够跨入口读到 A=10/B=22。

    这些毫秒级结果只证明本次实际断连路径及时报错,不等于已重现并修复原始长期负载下的 150 秒停滞。 该路径 TCP EOF 很快可见,不能据此单独证明所有 backend 重试路径都遵守 10 秒预算;预算语义另由定向源码测试验证。

    底层定向验证

    覆盖 12 个已有测试:嵌套预算取最早截止时间、失联 backend、调用方取消、健康请求不被缩短、bind refresh 剩余预算和已过期预算、在途重试、健康锁等待、取消后的错误返回、换 bind 不重置预算及预算耗尽退出。普通运行每项 10 次,120/120 通过;race 每项 3 次,36/36 通过,未报告数据竞争。

    历史交付与当时未完成项

    • 已追加到现有 MOTR Fix bug of merge empty batch #353,目标分支 4.2-dev;提交 12df74672c4ce79c23f706126d0570e6d6d97a44。没有新建 MatrixOne 主库测试 PR。
    • 回归文件:.github/qa/issue_32834_topology.py、issue_32834_cn_loss.py、run_issue_32834.py;现有 QA 4.2 remote lock rollback cleanup 33166 job 增加普通/race 定向测试及三轮真实 CN kill/restart。
    • main 的现有 MOTR MOServer cannot handle requests bigger than MaxPayloadSize #374 只提供薄调度入口,显式检出 MOTR 4.2-dev 并执行对应 action。需先合入 Fix bug of merge empty batch #353 再合入调度入口;未合入不能声称已每日运行。
    • 新增回归运行 46139698673 的 job 没有执行任何 step,平台 annotation 为 The job was not started because an Actions budget is preventing further use.,因此 CI 尚未验收,并非测试断言失败。
    • 仍需原始持续 Sysbench/Chaos 负载、对应并发/故障时间窗口与完整回归 CI。当前本地独立进程验收不能替代这部分证据。

    2026-11-30 Linux CI 补验(原 CI 阻碍已解除)

    • 实际官方 4.2-dev SHA:2bdc8daf527846ace58ab465c33127d02174e83b。运行时由三个 SQL 入口核验完整版本,不混用 main。
    • MOTR run 46285969925 已完成,结论 success。测试交付仍在现有 MOTR #353,不新建产品仓库 PR。
    • 已下载并核对该 run 的小型证据附件 qa33166-42-acceptance(约 14 KB),不是仅依据 Actions 绿色标记判断。
    • 修正测试夹具的端口选择:三轮使用彼此独立、低于 Linux 默认临时端口范围的端口组。此前第三轮 EADDRINUSE 属于启动前检查失败,既不计作产品失败,也不计作通过。
    • 每轮为 2 CN、1 TN、3 voting LogService、1 Proxy,独立服务进程;真实 SIGKILL 持锁 CN2,同版本/配置/数据目录重启,无产品代码 overlay。
    Linux 轮次 健康持锁等待后成功 SIGKILL 后在途请求返回 owner 缺失新请求返回 重启后实际写就绪 原子性与跨入口数据
    1 12.2182 s 10.0091 s 10.0027 s 0.9174 s 通过,A=10 / B=22
    2 12.2183 s 10.0118 s 10.0020 s 0.9187 s 通过,A=10 / B=22
    3 12.2188 s 10.0082 s 10.0026 s 0.9184 s 通过,A=10 / B=22

    这次 Linux 故障路径实际返回:

    20505 cannot connect to backend: backend availability retry budget exhausted
    

    三轮均在约 10 秒返回,确实走到了 backend retry budget 耗尽路径;与此前 macOS 快速 EOF 的毫秒级路径不同。健康 backend 上先等待超过 12 秒后仍成功,说明没有简单地把全部正常锁等待截断为 10 秒。

    三轮重启后的首个写尝试均记录过一次 20702 lock table bind changed,新连接/事务重试后约 0.92 秒恢复;未隐去这些瞬态错误。故障事务回滚后核对 A=10/B=20,恢复的新提交经 CN 和 Proxy 读回 A=10/B=22。底层 12 个预算测试普通各 10 次、race 各 3 次均通过,120/120 与 36/36;其作用是补充具体 context 传播及取消语义证据。

    本轮补充:真实插入负载中的三轮 CN 故障与全重启

    • 官方 4.2-dev@91c59a43bd519f7cccee408035cbf6c5b13dc0e2,服务二进制 SHA256 b2ea51fca495e858ff066c9bbf617a38c86e86a8cefcb7775b0dffdf0d60663d,无产品源码 overlay。两个 CN 与 Proxy 各自核对完整 git_version()。
    • Linux128 独立网络/目录,3 LogService + TN + 2 TP CN + Proxy;10 GiB 总内存及 swap 合并限额,4 CPU。未使用129、未停止其他任务。
    • 实际 mo-sysbench 源码 1a7886fc7566dfc9fd85a81801f09471151365d3,10 表,每表预置100,000行,10线程,真实 oltp_insert.lua 连续600秒;使用持久连接,经Proxy写入。设置 mysql-ignore-errors=all 以继续经历故障,不代表没有错误。
    • 第60/240/420秒开始各一轮独立审计表测试:观察 mo_locks 中实际持锁CN和等待事务,先验证健康持锁等待超过12秒可成功,再真实SIGKILL目标CN;记录在途请求与owner缺席时新请求的返回,恢复同一CN,验证回滚及新提交。
    轮次 健康持锁等待后成功 在途UPDATE总耗时/返回 owner缺席时新UPDATE 恢复与原子性
    1 12.2396 s 0.0426 s,1105 connection reset by peer 10.0016 s,20505 budget exhausted 双CN/Proxy回滚10/20,新提交10/22
    2 12.2178 s 0.2625 s,1105 connection reset by peer 10.0024 s,20505 budget exhausted 同上
    3 12.2227 s 0.2571 s,1105 connection reset by peer 10.0022 s,20505 budget exhausted 同上

    在途UPDATE总耗时从提交查询开始计时,杀CN后由轮询观察到完成约1.03–1.06秒(包含采样间隔),不是恢复SLA。每轮重启后首次写都经历一次20702 lock table bind changed,重新尝试后成功,未忽略该瞬态。

    原始负载汇总:

    transactions: 896191 (1493.64 per sec.)
    ignored errors: 65
    reconnects: 11
    total time: 600.0032s
    latency avg: 6.69 ms
    latency p95: 26.68 ms
    latency max: 12135.44 ms
    

    故障窗口出现吞吐下降和错误,随后恢复到持续写入;不能描述为“全程零中断”。结束时实际10表合计1,896,197行。它比初始百万行加Sysbench已计事件数多6行,断连时提交结果存在不确定性,本脚本没有逐条客户端ACK账本,不据此认定重复写或宣称所有ACK逐条一致。

    负载结束后对10表分别保存 COUNT、SUM(id)、SUM(k)、BIT_XOR(CRC32(c||pad)),完整停止并重启7服务,再计算指纹全部一致;3个审计库通过两个CN/Proxy再次精确读到10/22。指纹检查不是全量逐字节行对比。两次完整停机共14个正常退出码0,3次计划SIGKILL分别明确记录为-9。

    同一官方源码的12个预算测试再次普通模式各10轮、race各3轮:120/120与36/36通过,0失败。错误预算、较早deadline、正常锁等待、取消和bind刷新不重置预算均覆盖。

    测试驱动开发中的失败也保留:首次 Lua 加载到了系统同名公共模块,缺check_reconnect,尚未注入故障;修正LUA_PATH。第一次故障快速返回1105连接重置,旧断言只接受20505/20702,修正为仅接受明确的reset/refused/broken-pipe传输错误;另一版在owner缺失时额外A表更新先触发10秒预算,后改为直接测B表新请求,故障前A更新及回滚原子性仍完整保留。最终上述三轮来自全新目录完整重跑,未把这些初稿失败算成产品修复失败。

    回归补充

    新驱动 issue_32834_sysbench_load.py 与说明已加入现有 MOTR 4.2-dev #399,提交 2532d60,未向MatrixOne主库提PR。旧的预算/无负载CN故障回归仍保留。

    CI 46752321699 在私有 mo-sysbench checkout 返回 Repository not found,产品测试未执行。已将该私有依赖从无关IVF门禁中移出,新十分钟负载驱动当前需挂载有权访问的固定源码手动执行,尚未实现该负载专项每日执行;不能把旧CI绿色结果代替它。

    待解决点

    • 原始多小时稳定性负载及自然Pod Chaos窗口尚未等价覆盖;本轮是10分钟确定性故障,不外推所有原150秒停滞根因均消失。
    • 新负载专项托管CI/每日接入还缺私有源码读取权限;不提交凭据或私有源码副本到公开回归。

    最终结论:未完成验收。已通过项:最新4.2-dev十分钟百万行种子Sysbench、三轮真实CN故障、约10秒预算、回滚及恢复写入、完整重启指纹和156次预算测试。未完成项:原始长稳/自然Chaos等价场景、新负载专项托管CI与每日接入;保持开放,不转派。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions