Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues. Parent issue [Bug]: CN can panic on clean restart when view metadata admission misses startup deadline #27945 tracks the standalone clean-restart failure; this issue tracks the distinct TN RPC drain invariant required by that lifecycle.
Branch Name
main
Commit ID
c46d897e9645b80178568ef0783dd8e99e527222
Other Environment Information
- Hardware parameters: mo-55 bare-metal validation host; resource thresholds remained above 12 GiB MemAvailable and 100 GiB root free space.
- OS type: Linux amd64.
- Deployment: single-process standalone containing CN, TN, LogService, and HAKeeper.
- Workload: retained 2,303,643-row FULLTEXT2 runtime with two accepted TN transactions in flight during
SIGTERM. - Parent lifecycle issue: [Bug]: CN can panic on clean restart when view metadata admission misses startup deadline #27945.
- Implementation PR: fix(txn): quiesce and drain TN RPC handlers before storage close #28016, logically dependent on PR fix(service): shut down standalone services in dependency order #28015.
Actual Behavior
During standalone graceful shutdown, accepted TN transaction RPC handlers can remain active while TN replicas or storage are being cancelled and while the process-level shutdown advances toward LogService shutdown.
In the captured failure, exactly two TN RPC workers remained inside the transaction commit path:
TN transaction RPC worker
→ TAE Txn.commit1PC()
→ txnStore.WaitWalAndTail()
→ WAL entry.WaitDone()
→ LogService append
The TN RPC server does not expose a lifecycle boundary that first rejects new producers and then drains already accepted handlers. Queued, local-dispatch, forwarded, and active requests therefore do not share one sealed accounting model, and shutdown cannot prove that every accepted handler reached a terminal state before replica/storage dependencies are closed.
This can make a dependency-ordered standalone shutdown stall or destroy resources still needed by accepted commits. It also makes repeated or concurrent close behavior difficult to reason about.
Expected Behavior
TN transaction RPC shutdown should follow a private, bounded lifecycle:
Quiesce
→ Drain accepted handlers
→ Close replicas and storage
After the quiesce linearization point, network and local-dispatch producers must be rejected and the accepted-handler count must not increase. Queued requests must be cancelled and released exactly once. Active handlers must retain replica, storage, and WAL dependencies until they reach a terminal state.
If drain reaches its deadline, shutdown must return a deterministic error without destroying dependencies that active handlers still require. A commit that has entered the durability stage must not be reported as rolled back merely because the client disconnected or shutdown began.
Steps to Reproduce
- Start a standalone MatrixOne process containing CN, TN, LogService, and HAKeeper.
- Establish at least two transaction RPC requests and pause or delay them after the server has accepted them but before their WAL durability terminal is published.
- Send
SIGTERMto begin graceful standalone shutdown. - Observe TN shutdown while the accepted RPC handlers are still active.
- Without an explicit quiesce/drain boundary, new/local producers can race with shutdown and replica/storage cancellation can overlap the accepted handlers.
- Confirm the terminal wait chain with the TN RPC worker and WAL waiter goroutine stacks.
The deterministic regression coverage for the fix should exercise queued, forwarded-wait, local-dispatch, handler-active, and durability-stage requests, including repeated close and drain timeout.
Additional information
- Scope: private TN and transaction-RPC lifecycle only.
- Non-goals: no SQL, DDL, public RPC interface, transaction wire protocol, persisted format, owner timeout, discovery timeout, or transaction-outcome semantic change.
- PR dependency: PR fix(service): shut down standalone services in dependency order #28015 must establish process-level dependency ordering first. PR fix(txn): quiesce and drain TN RPC handlers before storage close #28016 must be rebased to a B-only diff after PR fix(service): shut down standalone services in dependency order #28015 merges.
- BVT: N/A. SQL BVT cannot deterministically stop an RPC at queued/active/durability boundaries while delivering process shutdown and asserting internal dependency lifetime. Package and race tests must cover those terminals, followed by an A+B in-flight-commit standalone test.
- QA required: yes. The production terminal is an accepted transaction during graceful shutdown; exact-head in-flight-commit E2E remains required before closure.
Activity
fix(txn): quiesce and drain TN RPC handlers before storage close (#28016
VioletQwQ-0 commentedon Sep 9, 2026
转 QA:开发侧证据交接(非正式 QA PASS)
验证绑定合入版本
92a6bceba1ee156b87dc340479aa1cd44fe56a3d,A+C 对照为585a38efd152fadf216c8675b7b997a35ca8deb1。wrappedClient.Append前的 pending entry,3/3 通过;D1/D2/U2 使用测试专用 overlay,仅标记
INSTRUMENTED_RUNTIME_VERIFIED;原版 binary 用于恢复检查。两次早期 U2 harness 失败已保留并排除,不计入通过次数。证据包:
/home/sunyuze/lifecycle-closeout-v2-e295-20260908-01/qa-closeout-20260909/real-wal-boundary-20260909-final/;manifest SHA256:b874e69507bebf2c4da96317bba4d8542236c43d4cf786471210585130052ee8。请 QA 绑定 exact 版本和环境复核 Quiesce/Drain、依赖关闭和事务恢复;本评论表示开发证据已提交,不表示正式 QA PASS。issue 保持 OPEN。
Ariznawlll commentedon Sep 11, 2026
回归补充
已新增独立回归 PR #28730,不与 SQL/MOTR 用例混放。
TestIssue28012And28013AcceptedCommitDuringStandaloneShutdown;真实 embedded 单 CN/TN/LogService。WaitWalAndTail()、尚未执行on1PCApply的FJ_CommitWait。ff8516842d95138c2c73a7e1a520fce088708459,目标用例连续3/3通过;go test ./pkg/tests/issues/isolated -count=1通过。该 PR 仅补充自动化 QA gate,当前等待 review、CI 和合入 main;在合入后的 exact-head 复验完成前,此 issue 保持 Open。
fix(txn): quiesce and drain TN RPC handlers before storage close (mat…
fix(txn): quiesce and drain TN RPC handlers before storage close (mat…
fix(txn): quiesce and drain TN RPC handlers before storage close (mat…
test(embed): cover accepted commit during standalone shutdown (#28730)
iamlinjunhong commentedon Sep 24, 2026
2026-09-24 CI evidence for PR #29152
The source PR is still open at exact head
18341dda0710d94461fee48db2750b9a218ba693. Run35870543875, attempt 1, has three failed checks:TestIssue28012And28013AcceptedCommitDuringStandaloneShutdown. The test did not observe the TNdrainWaitersfault point within 30 seconds (pkg/tests/issues/isolated/issue_28012_28013_shutdown_test.go:146); cleanup then reportedissue 28012/28013 goroutines did not exit within 30sandbad connection. The same log records a timeout subscribing tomo_debug.trace_featuresand refused task-service connections during shutdown.matrixone-ut-coverage: failure, downstream of the UT result.An independent Linux/x86 CI failure of the same exact test occurred on unrelated PR #28730: run 35332206856, attempt 1, job 105558897895. It ended with
context deadline exceededafter embedded-cluster admission waited about 2m59s; that run reports the test elapsed 222.69s. The low-level timeout point differs, but both are timeouts in this shutdown regression case. The maintainer analysis and the test contract linked from this issue cover TN handler drain while an accepted commit is blocked.The current exact head's separate Linux/x86 UT job 107213274028 succeeded and reports this same test passing in 32.95s. The failing case and TN RPC/WAL drain implementation were not changed by PR #29152. The only nearby shutdown edit adds optional UDF runtime cleanup in CN; this test leaves Python disabled, so CN receives an empty runtime registry whose
Closehas no runtime to close. The failed job runs the externalmatrixorigin/CIcoverage workflow, not theoptools/run_ut.shpath also edited by the PR.The evidence matches the existing open shutdown lifecycle/test-contract issue and its independently observed Linux/x86 timeout class. The other two current failures are downstream of the UT producer failure. This run is recorded here for the single authorized failed-jobs rerun.
Ariznawlll commentedon Sep 24, 2026
测试版本
maind7d940e93bd037e9aacdc0f1256b91e32df84642原问题验证
执行精确回归
TestIssue28012And28013AcceptedCommitDuringStandaloneShutdown,连续运行 3 次,覆盖 standalone TN 在已接受 commit 与 storage shutdown 并发时的 drain/quiesce 行为。测试 3/3 通过,总耗时 55.218s,未出现 RPC handler 在 storage close 后继续访问导致的失败。正常场景覆盖
异常与边界覆盖
白盒验证
该问题依赖内部 fault injection、TN 生命周期和 restart 检查,精确覆盖位于 MatrixOne Go integration test;SQL 黑盒 MOTR 无法可靠制造“commit 已接受但 handler 尚未 drain”的内部时序,因此不重复添加一个弱化用例。
回归测试
TestIssue28012And28013AcceptedCommitDuringStandaloneShutdown-count=3测试证据
测试结论
测试通过。
test(embed): renew SQL deadline after restart admission (#29398)