Repository navigation
Description
Environment
| Field | Value |
|---|---|
| Cluster | TKE Main Nightly Regression |
| Namespace | mo-main-commit-3c04dacaa-20260730 |
| MO commit | 6f85cb6d3c |
| Topology | 3 CNs (tp-cn-qkwt7, tp-cn-tgcjf, tp-cn-xpp82), 1 DN, 2 Proxies |
| Run | https://github.com/matrixorigin/mo-nightly-regression/actions/runs/30563962387/job/90984768719 |
Summary
TPCC 1000 warehouses / 1000 terminals fails with 2 ErrorCode: 20502 (backend connection closed) on TT_NEW_ORDER transactions within 2 seconds of test start (20:22:46 start → 20:22:48 error).
Error Chain (from Loki server-side logs)
20:22:48.053 tp-cn-qkwt7 lockservice/log.go:285 failed to lock on remote err=backend connection closed (×2)
20:22:48.665 tp-cn-qkwt7 frontend/session.go:2385 backend connection closed
20:22:48.666 tp-cn-qkwt7 frontend/session.go:2385 query trace status err=backend connection closed (×2)
20:22:49~50 tp-cn-qkwt7 lockservice/log.go:633 failed to valid txn err=backend connection closed (×7)
20:22:49~54 proxy pods session.go:515 close connection failed err=use of closed network connection
The root cause is an inter-CN MORPC connection closure during distributed lock acquisition in the lockservice. CN tp-cn-qkwt7 attempted to acquire a remote lock on another CN, but the MORPC backend connection was already closed, which cascaded into:
ErrBackendClosed(20502) returned to the TPCC client via frontend- 7 additional
failed to valid txnerrors from lockservice - Proxy connection cleanup errors
TPCC Results
| Spec | tpmC | Errors | Result |
|---|---|---|---|
| tpcc_10 (10w/10t) | 12,119.8 | 0 | ✅ PASS |
| tpcc_10 (10w/100t) | 42,927.1 | 0 | ✅ PASS |
| tpcc_100 (100w/100t) | 50,176.6 | 0 | ✅ PASS |
| tpcc_100 (100w/1000t) | 51,340.8 | 0 | ✅ PASS |
| tpcc_1000 (1000w/1000t) | 23,118.8 | 2 | ❌ FAIL |
Consistency check passed — no data corruption.
History
- Same commit
6f85cb6d3cran TPCC successfully earlier the same day (run 30472882209, 0 errors) - Past 7 days of TKE main nightly TPCC: all 0 errors
- First occurrence in normal nightly workload
Related Issues
- [Bug]: merge-trigger-tke TPCC repeatedly fails after inter-CN MORPC backend closes and transactions are marked orphan #25779 — merge-trigger-tke TPCC: inter-CN MORPC backend closes, transactions marked orphan (CLOSED, marked "fixed")
- [Bug] Chaos (33bc7a2): TPCC New-Order
1062 Duplicate entryonbmsql_oorderundertask_mem_cn+20502(no co-timed20638) #25784 — Chaos TPCC: NEW_ORDER + 20502 undertask_mem_cn(CLOSED)
Same root cause (inter-CN MORPC connection closure during lock acquisition), but this is the first time it appears in normal nightly TPCC workload without chaos injection or merge triggers.
Expected Behavior
1000 terminals establishing connections simultaneously should not cause inter-CN MORPC connections to be closed during distributed lock acquisition.
Activity
Ariznawlll commentedon Jul 31, 2026
详细分析
1. 完整故障链
错误不是孤立的,分为两个阶段:
阶段一:TPCC 启动期 MORPC 连接中断 (20:22:48)
阶段二:级联失败 + 后续全集群 database closed (20:22:49 ~ 20:23:50)
2. 关键发现
错误发生在启动后仅 2 秒:tpcc_1000 在 20:22:46 开始执行,20:22:48 就报错。1000 个 terminal 同时建立连接并发起分布式事务,造成瞬时连接风暴。
影响范围远超 2 个事务:
failed to valid txn(已有事务的锁验证失败)sql: database is closed错误CN 自身没有 crash/restart:Exec.Run 日志显示 CN 在 20:22:54 仍在正常处理查询(Exec.Run 时间 1.4s~8.2s),说明是 MORPC 连接层问题,不是 CN 进程问题。
3. 为什么认为是 bug 而不是偶发网络抖动
tp-cn-qkwt7,不是随机分布lockservice/log.go:285→frontend/session.go:2385,是 lockservice 获取远程锁时检测到 MORPC 连接关闭sql: database is closed4. 可能原因
lockservice/log.go:285在获取远程锁时遇到连接关闭,直接返回错误而不是重建连接重试sql: database is closed级联说明可能有关联的连接管理问题5. 建议修复方向
failed to lock on remote时增加 MORPC 连接重建 + 重试机制sql: database is closed级联的根因(是否与 MORPC 连接关闭有关联,还是独立问题)XuPeng-SH commentedon Jul 31, 2026
Reference: correlated Loki/Prometheus evidence
Conclusion — confirmed, high confidence: the two
20502: backend connection closederrors were not direct evidence that the peer CN or TCP connection had already closed. The immediate trigger was a local lockservice MORPC backend auto-create timeout at the 500 ms boundary during the TPCC startup transaction burst. The affected CN was simultaneously at critical cgroup memory usage, so the lock retry guard intentionally stopped retrying and the two transient failures escaped to SQL.The MatrixOne commit printed by this TPCC job is
3c04dacaa606b643e815bdf8535988d0e4576e12. The shorter commit currently mentioned in the issue is the workflow repository revision, not the MatrixOne build revision.Correlated timeline (UTC)
20:22:46: TPCC starts the 1000-warehouse / 1000-terminal transaction phase. All 1000 terminal connections had already been created; this was a transaction-start burst, not 1000 simultaneous connection establishments.20:22:47.553: lockservice creates a remote bind.20:22:48.053: two remote-lock attempts fail almost exactly 500 ms later withbackend connection closed.20:22:48.417: the same bind is closed askeeper-failed.20:22:48.665: keeping remote locks fails; both retries are stopped by the critical-memory guard and both retry budgets terminate.20:22:48.665–20:22:48.666: the two errors are returned through the frontend.The code at the tested revision closes the chain:
pkg/lockservice/rpc.goconfiguresWithClientAutoCreateWaitTimeout(500*time.Millisecond).pkg/common/morpc/client.gomapsErrBackendCreateTimeouttomoerr.NewBackendClosedNoCtx(), so a local backend-creation timeout is exposed externally as error 20502.Memory pressure: amplifier, not the original trigger
At the closest scrape after the event, the affected CN had:
The lock retry policy uses cgroup memory usage and stops retrying at the critical threshold (90%). Therefore memory pressure explains why the transient backend-create timeout was not recovered, but it does not explain the first 500 ms timeout itself. Since cgroup usage includes cache, follow-up observability should retain both usage and working-set values when evaluating this guard; the evidence here does not by itself prove that the current policy is wrong.
First-principles causal chain
backend connection closed, conflating local scheduling delay with peer failure.The run continued for five minutes, completed 116,385 transactions including 52,150 NewOrders, and passed the consistency check. This bounds the observed impact to two escaped transient transaction errors; no corruption signal was observed.
Relation to #26473
#26473 directly addresses the primary trigger and classification gap by separating local queue budget from peer factory budget, using a bounded multi-worker create pool, rejecting stale generation results, isolating lockservice transport roles, and preventing local queue timeout/full conditions from poisoning the peer breaker.
It should not yet be considered proven for this incident until the same TPCC 1000w/1000t startup pattern is replayed. Suggested acceptance evidence:
The initial backend-create problem and the memory retry policy are related but distinct control loops. Fixing the former substantially reduces the probability of this failure; the high-memory replay is still needed to verify the combined unhappy path.
XuPeng-SH commentedon Jul 31, 2026
Follow-up: why critical memory stops lock retries
This is an intentional load-shedding / OOM-prevention policy, not evidence that memory pressure caused the original MORPC timeout.
The policy applies to the bounded backend/bind availability retry path, rather than to every normal lock conflict:
The first-principles rationale is that a waiting transaction is not free. It can retain pipeline state, batches/vectors, lock rows, transaction metadata, RPC state, timers, and referenced buffers. Under a backend outage or recovery delay, many concurrent retries can therefore form a positive feedback loop:
backend unavailable -> more retained transactions -> more memory/RPC pressure -> slower recovery -> more retriesFailing the transaction at the critical threshold attempts to break that loop and release resources before the container is OOM-killed. This is a survival-over-availability decision.
However, the current signal is coarse.
defaultLockRetryMemoryPressureLevelusessystem.MemoryUsed()/MemoryTotal(), and in a containerMemoryUsed()reads total cgroup usage, which includes page cache. At this incident's closest scrape, total cgroup usage was 99.9%, while working set was 86.8%, cache was 14.09 GiB, and there were no OOM events or restarts. The guard therefore behaved as implemented, but the measurement does not prove that 99.9% was all unreclaimable pressure.The remaining policy risks are:
The systemic follow-up should not simply raise the threshold. It should evaluate a pressure signal based on actual headroom and reclaimability, add hysteresis/sustained sampling, preserve a strictly bounded recovery lane where safe, and expose the pressure level and stop reason as metrics.
#26473 addresses the initiating backend-create congestion and its incorrect peer-failure classification. It does not materially change this memory guard, so the same high-memory TPCC replay is still required to validate the combined unhappy path.
aptend commentedon Jul 31, 2026
Independent re-review
After independently checking the TPCC job log, the 5-minute Loki/Prometheus window around the failure, and the code at the tested MatrixOne revision (
3c04dacaa606b643e815bdf8535988d0e4576e12), I agree with the follow-up analysis.The evidence supports this causal chain:
ErrBackendCreateTimeoutreused theErrBackendClosedcode/message, which explains the externally visible 20502 classification.sql: database is closedmessages do not establish the initiating causal chain.The independent checks also found a useful control case: another CN hit the same approximately 500 ms lock-client auto-create timeout pattern while below the critical-memory threshold, but no additional TPCC client errors escaped. This is consistent with retry policy being the difference between recovery and frontend exposure.
I therefore agree that #26473 addresses the primary trigger and classification/lifecycle gaps and is the appropriate solution for this incident. Final incident closure should still require replaying the same TPCC 1000w/1000t startup pattern, including the high-memory condition, and confirming that no frontend 20502 escapes and that local queue pressure is reported separately from real peer connection failures.
fix(lockservice): scope backend create timeout to recovery (#26553)
Ariznawlll commentedon Aug 3, 2026
最近几天没再出现,先关闭
fix(lockservice): scope backend create timeout to recovery (matrixori…
fix(lockservice): scope backend create timeout to recovery (matrixori…
fix(lockservice): scope backend create timeout to recovery (matrixori…