Skip to content

test(embed): cover accepted commit during standalone shutdown - #28730

Merged
mergify[bot] merged 11 commits into
matrixorigin:mainfrom
Ariznawlll:codex/standalone-txn-shutdown-28012-28013
Sep 21, 2026
Merged

mergify[bot] merged 11 commits into
matrixorigin:mainfrom
Ariznawlll:codex/standalone-txn-shutdown-28012-28013

Conversation

@Ariznawlll

@Ariznawlll Ariznawlll commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #28012
issue #28013

What this PR does / why we need it:

Adds focused standalone lifecycle regression coverage for #28012 and #28013.

  • scopes the existing commit-wait fault to one tenant, so the test can hold one accepted transaction after WaitWalAndTail and before on1PCApply without stalling unrelated tenants;
  • starts the real embed.Cluster.Close() path while that transaction is held, lets transaction-server drain advance, and verifies that TN teardown and full standalone shutdown cannot complete before the accepted handler reaches a terminal state;
  • restarts the same cluster and verifies statement atomicity/durability, then confirms that a fresh transaction succeeds;
  • registers SQL clients for cleanup before PingContext, with focused tests for ping failure and context cancellation;
  • adds narrow fault-injection observation points around active-handler drain and pre-storage teardown. They are inert unless a test installs the corresponding fault points.

This PR adds regression coverage and test instrumentation only; it does not change normal production shutdown behavior.

Verification

  • focused standalone shutdown test: passed in normal and race modes;
  • focused pkg/objectio, pkg/tnservice, pkg/txn/rpc, and pkg/vm/engine/tae/txn/txnbase tests: passed;
  • current-head required CI, UT coverage, and SCA: passed.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head d76a14cb4497254252ddbc44d149218f696e8045. Two P2 test blockers remain:

  1. Fault cleanup can strand the accepted transaction on assertion failure. In issue_28012_28013_shutdown_test.go, defer fault.Disable() runs before the later t.Cleanup. If an assertion fails before commitRelease, the transaction remains blocked in FJ_CommitWait; Disable removes/stops the fault map but does not wake its WAIT channel, so cleanup cannot remove the fault and cluster.Close() may wait through TN drain (up to four minutes), leaving the worker stuck. Cleanup should release/remove the WAIT first, join launched goroutines, close the cluster, then disable faults.

  2. The test does not prove commit overlaps TN drain. The new hook is reached before cluster lock and service teardown. After observing hook entry, the test waits a fixed 200 ms then releases commit; CN/frontend shutdown may not yet have reached the TN drain dependency. A regression in TN drain ordering could therefore pass. Synchronize on the actual admission/drain boundary and the still-active accepted handler before releasing commit.

Exact-head CI run 34814895299 passed; the race-UT job took 49m40s total. I could not obtain per-test timing, so this is not evidence that the new case is below the ~45s single-test limit. No timing pass is claimed.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review(Astra medium,head 277d5e5)

REQUEST_CHANGES:发现 1 个 P2 测试生命周期问题;未确认 P0/P1 生产回归。

  • [P2] issue_28012_28013_shutdown_test.go:233-235:sql.Open 启动 database 的 connection-opener goroutine,但当前在 Ping 成功前没有注册 cleanup。若 Ping 失败,require.NoError 会直接终止测试,调用方不会把该 DB 加入 dbs,DB.Close 也不会执行,可能遗留客户端 goroutine。建议 sql.Open 成功后立即注册 t.Cleanup/关闭登记,再执行 Ping;同时使用 PingContext(ctx),避免 Ping 使用 background context 逃逸测试的两分钟取消预算。

其余检查:shutdown 的 quiesce、active-handler drain、replica/storage teardown 顺序未发现新的所有权冲突;waiter 唤醒、commit/abort 终态和 restart/reuse 路径未发现新的 P0/P1。该测试确实改善了 accepted-commit during standalone shutdown 的回归覆盖,但 500ms negative-observation window 不是 scheduler-independent proof,且当前 head 的 build/UT/SCA/coverage 仍在 CI 中。

CI run:https://github.com/matrixorigin/matrixone/actions/runs/35224914136

@Ariznawlll

Copy link
Copy Markdown
Collaborator Author

已按最新 review 修复并 push(4275fc0749):

  • sql.Open 成功后立即把 DB 登记到统一 cleanup 列表,再执行 Ping;即使 Ping 失败,外层 cleanup 仍能关闭 connection-opener。
  • Ping 改为 PingContext(ctx),受测试的两分钟取消预算约束。
  • 保留原有 cleanup 顺序:先解除 WAIT fault、等待 goroutine,再关闭 DB/cluster,避免直接使用后注册的 t.Cleanup 反转顺序。
  • 新增回归测试,覆盖 Ping 失败前已登记 DB,以及已取消 context 会中止 Ping。

验证:

  • cleanup/context 单测:PASS;
  • cleanup/context 单测 -race:PASS;
  • standalone shutdown focused test + 新单测:PASS(18.425s);
  • git diff --check:PASS。

未手动触发外部测试环境;push 后的 required CI 由 GitHub 自动运行。

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review (Astra medium, exact head 4275fc0)

APPROVE.

Reviewed all changed hunks in all eight files, including tenant-selector consumers, accepted-handler accounting, standalone shutdown ordering, WAIT removal, assertion-failure cleanup, restart ownership, and transaction atomicity oracles.

No concrete blocking findings remain. The previous DB cleanup defect is fixed: registration precedes PingContext, with focused failure/cancellation coverage. This is regression coverage with narrow fault-injection hooks; the large-feature design gate does not apply. The dedicated cluster is justified by destructive shutdown and restart.

Reused exact-head CI run 35304429553, including confirmed execution and passing race results for the shutdown scenario and both DB cleanup tests. git diff --check passed.

@iamlinjunhong
iamlinjunhong self-requested a review September 18, 2026 09:08
@mergify

mergify Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-21 07:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-21 08:16 UTC · at 921331015121315ee937c401829a594c10579809 · squash

This pull request spent 56 minutes 5 seconds in the queue, including 55 minutes 46 seconds running CI.

Required conditions to merge

This branch was previously deployed

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

Labels

kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants