Repository navigation
fix(txn): quiesce and drain TN RPC handlers before storage close - #28016
Conversation
0f684ed to
1ed6768
Compare
|
@XuPeng-SH The forward-wait test finding is addressed in The worker's second Validation: both changed tests pass normally; each top-level test passes 100 race repetitions; the RPC package passes normally and under race. Removing the production Please re-review the test repair. The cross-service acceptance request remains open: A+B in-flight commit SIGTERM, shutdown order, 10 same-UUID restarts, and SIGKILL fence evidence have not been supplied by this update. I am not treating package tests as proof of real LogService handoff or asking to waive that gate. The PR body now also reflects the actual Ready UI state without claiming runtime acceptance is complete. The local-dispatch microbenchmark remains an optional follow-up; no lease optimization was made. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 781820f against base/merge-base 7e6cb6a: APPROVE for the source change. The outstanding cross-service QA acceptance listed below is not claimed complete. Under the current maintainer review direction, missing test evidence alone is not a REQUEST_CHANGES blocker when no verified source correctness/concurrency/unhappy-path failure remains.
The previous forward-wait regression defect is fixed. The single worker's second Done() evaluation holds execution after dequeue, beginHandler and TxnForwardWait state selection; it no longer treats the pre-incremented active count as proof of worker entry. The two cases exercise waiting and readiness-promotion versus quiesce, require exactly one cancellation, zero forwarding, a reset request, zero active handlers and a joined worker. Cancellation/release/join cleanup is installed before launch/assertions. The accepted-handler test now uses a deadline-bearing Drain directly instead of trying to bound a blocking callback with Eventually. The author also reports a discriminating negative control that removes the production stoppingC arm and fails the repaired waiting case without stranding the test worker; that report is attributed evidence, not my own run.
I read all changed hunks in the complete seven-file B-only diff, checked the exact test-only delta from 1c84b15, and traced the network queue, active-handler accounting, forwarding, cached local dispatch and actual standalone shutdown consumers. Production content is unchanged from the previous reviewed head. Quiesce seals admission before waiting for admitted producers; queued/dequeued cancellation and ordinary execution have separate exactly-once cleanup paths. Cached local closures acquire a call-time lease. Network and local drains use the same store deadline, and failure returns before replica cancellation/storage destruction. Concurrent/repeated closes share the terminal result.
The actual service supervisor stops TN before LogService, propagates TN Close failure through its role task, and returns without initiating the next dependency shutdown phase. I am not reopening the already-corrected TN-to-LogService ordering or interpreting an unknown commit outcome as rollback.
| Audit | Closure |
|---|---|
| Q1 / generation | Admitted requests and local leases remain counted until their terminal owner releases them; request pools are reset on release; close does not reopen admission. |
| Q2 | Forward-wait observes stopping/cancellation; accepted execution drains while dependencies remain available; timed-out drain prevents dependency teardown and leaves fail-stop/recovery to the supervisor. |
| Q3 / performance | Existing queue/worker bounds remain; local dispatch adds bounded per-call locking/closure overhead, not a new unbounded cache or queue. A microbenchmark is optional, not a reason to remove call-time admission. |
Validation: exact-head MatrixOne ALL CI 34195541983 is successful and git diff --check passes. Reviewed the source/oracles and reused the previous unchanged production/consumer review plus author-reported RPC focused/package/race and unchanged TN/native evidence with attribution; no new local native/race/topology run is claimed. This is a lifecycle bug fix with no public interface, wire, persisted-format or WAL outcome change, not a new protocol design.
Still incomplete QA acceptance, separate from this source approval: combined A+B in-flight-commit SIGTERM, real dependency-order evidence, ten same-UUID restarts, and a disposable SIGKILL owner-fence control. Component tests and green CI do not prove those cross-service results. Keep the outstanding QA record explicit and determine uncertain commit outcomes through recovery. I found no additional verified source blocker.
Merge Queue Status
This pull request spent 22 minutes 24 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28016 has been dequeued Queue conditions are not satisfied:
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Requeued — the merge queue status continues in this comment ↓. |
iamlinjunhong
left a comment
There was a problem hiding this comment.
P1 — drain timeout 后嵌入式关闭路径仍会销毁 TN 依赖
触发场景:嵌入式集群中已有 TN RPC commit 被接受,但在 4 分钟 drain deadline 内仍停在 WAL/存储终态,随后调用 `Cluster.Close()`。
-
`pkg/tnservice/store.go:378` 在 `drainHandlers` 返回超时后提前返回,这本身保留了 active handler、replica、storage 和 WAL,符合本 PR 的契约。但同一服务的调用方 `pkg/embed/operator.go:143-155` 在 `op.reset.svc.Close()` 返回错误后,仍无条件停止 stopper 并关闭 `op.reset.fs`。该 file service 正是 `operator.go:294-298` 传给 TN、并在 `pkg/tnservice/factory.go:108-124` 用来构造 TAE storage 的依赖;此时 active handler 仍可能在使用它。
-
`pkg/embed/cluster.go:248-249` 忽略 TN `Close` 错误并继续反向关闭后续服务。嵌入式服务顺序是 Log -> TN -> CN,因此 TN drain 超时后仍会关闭 LogService/WAL,而未终止的 commit handler 仍可能等待该 WAL。这样会把本应保留并交由恢复判定的 unknown commit outcome 变成依赖被销毁的失败路径。
请让嵌入式 owner 在 TN close 失败时保留 file/WAL 依赖和 cleanup owner,并停止后续 LogService teardown;同时补一个经过 `ErrTxnDrainTimeout` 的 embedded timeout regression。虽然上述两个 consumer 文件未在本 PR 中修改,但它们是本 PR 新增 early-return 语义的实际调用链,当前路径会破坏 PR 声明的 timeout contract。
P2 — 跨服务 QA 证据仍未完成
PR body 与作者在当前 conversation 的回复都确认,A+B in-flight-commit SIGTERM、真实依赖关闭顺序、同 UUID 重启和 SIGKILL owner-fence 证据仍未提供。该项不是本次 `REQUEST_CHANGES` 的源码触发条件,但不能由组件测试和绿 CI 代替。
本地复核:当前 head 的 7 个变更文件与原 head blob 相同,`git diff --check` 通过;本机定向 Go 测试受 CGo 环境缺少 `jemalloc.h/libmo` 阻塞,未宣称本地测试通过。
|
Addressed the embedded drain-timeout owner issue in
Validation on the exact pre-push content: |
Merge Queue Status
Waiting for
All conditions
|
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head bd37201 against current base 585a38e: APPROVE. I read the complete review history, author responses, full ten-file diff, the e295863..bd37201 incremental diff, and the actual embedded/standalone close consumers. There are no inline review threads.
The prior embedded drain-timeout blocker is closed. operator.Close now leaves the service object, operator stopper, and file service owned and live when service Close returns ErrTxnDrainTimeout. cluster.closeServicesFromLocked stops reverse teardown at that failed TN, so the earlier LogService/WAL dependency is not closed. A successful service close still releases those owners in dependency order; cluster admission and port leases are released only after all services close successfully. Because the real TN store caches the first Close terminal, a drain timeout is a fail-stop result rather than a claim that a later retry can resume that store; the retained owners keep the unknown transaction outcome recoverable until process recovery.
The previously reviewed network/local lifecycle remains closed over the full diff: admission and active accounting linearize with quiesce, queued and forward-wait requests have exactly-once cancellation/release, cached local handlers acquire invocation-time leases, and the TN shares one deadline across network and local drains before replica/storage teardown. The supervisor and embedded owner now both stop dependency teardown on a TN close failure.
Local exact-head validation:
- make thirdparties and make -C cgo: PASS
- changed embedded owner tests: PASS, count=20
- changed RPC/TN lifecycle tests: PASS, count=20
- all changed lifecycle tests across embed/RPC/TN under race: PASS, count=5
- complete diff check: PASS
Exact-head CI is not claimed green: its coverage job currently reports failure while other jobs are still running. Branch protection should keep that independent gate. The PR body also still names e295863 and a seven-file scope; it should be refreshed to the actual bd37201 ten-file scope for audit accuracy. The outstanding A+B SIGTERM, real dependency-order, same-UUID restart, and SIGKILL owner-fence QA evidence also remains explicitly unproven; I found no additional verified source blocker.
What type of PR is this?
Which issue(s) this PR fixes:
issue #28012
Related to issue #27945 and PR #28015.
What this PR does / why we need it:
During standalone shutdown, accepted TN transaction RPC handlers can still depend on replicas, storage, and WAL. Closing those dependencies before the handlers finish can interrupt transaction completion or leave shutdown waiting indefinitely.
Changes
The current remote head is
e295863d85fcd5e55116c0a939e6acc6bd99a6d7, with merge-base585a38efd152fadf216c8675b7b997a35ca8deb1. The range is B-only against the currentmainbase; the merge-from-main commit changes no additional TN/RPC lifecycle files. No SQL/DDL, public RPC interface, wire protocol, persisted format, owner fence, discovery timeout, or transaction-outcome semantic change is introduced.Validation
e295863d85fcd5e55116c0a939e6acc6bd99a6d7; complete diff is limited to the seven TN/RPC files in the B-only range.-race -count=10PASS for forward-wait quiesce and accepted-handler drain.781820fb5bc05b2a9db17857654265587e917885remains applicable because the current merge-from-main commit does not change the reviewed B implementation. Current-head CI is tracked separately and is not claimed complete here.gofmtandgit diff --check: PASS.pkg/txn/rpc/server_test.go,pkg/tnservice/store_rpc_handler_test.go, andpkg/tnservice/store_test.go; real cross-service acceptance remains required.Remaining acceptance and QA
PR A+B in-flight-commit SIGTERM, dependency-order evidence, ten same-UUID restarts, and the disposable SIGKILL owner-fence control remain outstanding. Component tests do not establish a real LogService handoff. Unknown commit outcomes must be determined by recovery and must not be described as rollback.
The PR is Ready for review; this UI state is not a claim of final approval or completed runtime acceptance. Merge/QA acceptance remains pending the cross-service evidence.