Skip to content

fix: release embedded cluster ownership after terminal cleanup - #29048

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/issue-29044-terminal-cleanup
Sep 17, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/issue-29044-terminal-cleanup

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #29044

What this PR does / why we need it:

A failed CN final metadata-withdrawal heartbeat is cached by Close. Embedded cleanup treated every close error as unfinished work, so it retained the completed CN, its TN/log dependencies, and the complete-cluster admission lease forever. Subsequent tests then failed admission rather than testing their own behavior.

Separate local completion from diagnostic errors. CN certifies completion only after local cleanup succeeds, while preserving the withdrawal error and remote generation fencing. Embed consumes this ownership contract to finish reverse cleanup and release leases even when returning a diagnostic. Unknown local/drain failures remain conservative: dependencies and cleanup owners are retained.

Make that completion assertion safe: frontend shutdown seals accepted-connection admission and joins connection handlers including deferred session cleanup. Cancel/join pipeline users before retiring Sirius/Mongo runtimes. Detached pending CNs close before TN/WAL dependencies; incomplete startup owners cannot be overwritten by another Start. Rollback and shared fixtures clear only completed owners.

Validation

  • Deterministic lightweight embed regression fails on unmodified production base at the retained-owner assertion and passes after the fix.
  • Focused normal lifecycle/withdrawal/pipeline/rollback/shared-fixture tests pass.
  • Incremental configured SCA (including govet), changed packages only: 0 issues.
  • Focused race lifecycle and three HAKeeper generation-fence controls pass; initial seven new tests each pass 100 separately selected race repetitions.
  • Owning-package race + scoped coverage pass: frontend 44.683s / 66.4%, cnservice 10.714s / 65.3%, embed 90.225s / 85.9%. Core embed close/completion/pending-cleanup functions have 100% statement coverage. These are package/function metrics, not a claim of full-repository or complete branch coverage.
  • Existing TestAutoIDCacheRestartAndDisabledNode passes under race (35.99s test time), preserving the original SQL assertions and three real close/admission-release cycles.
  • Additional non-nil-runtime ordering/failed-owner and real TCP pre-registration wiring tests pass in normal mode and 100 exact-test race repetitions, including guaranteed cleanup after failed assertions. No database fixture is used by these cases.
  • GPT-6 medium design and independent overall review (including final test-only deltas): PASS, no unresolved material blocker. Design agent 01a0ae02-a9bf-7311-b8bd-a341229dad00; review agent 01a0ae13-2848-7603-b11a-e244fb8a62c9, gpt-6-astra / medium, final diff SHA-256 6cf2e4bfd88c553553b34a2b9448b9d5db4d3a39aab77e96689e74f717f2eca2.

No new real-cluster fixture, BVT, sleep, retry, deadline extension, or weakened SQL assertion. New cases use existing fakes and barriers. This removes a demonstrated retained-service/admission cascade; no overall CI wall-time saving is claimed without same-mode CI measurement.

Local evidence uses Go 1.26.4 on Darwin arm64 with provenance-checked, independently built native libraries. The original HAKeeper timeout trigger is not established by this change. Unclassified local teardown errors remain fail-stop rather than being falsely certified complete. CI validation on Ubuntu/race is pending.

@XuPeng-SH
XuPeng-SH requested a review from aptend as a code owner September 17, 2026 06:51
@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 Author

Choose a reason for hiding this comment

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

Astra medium deep review at exact head f25cd2c. COMMENT ONLY (self-authored PR).\n\nNo confirmed P0/P1/P2 findings. Reviewed terminal cleanup/error certification, ownership retention and matching release, repeated Close/idempotence, detached-CN dependency ordering, rollback/restart blocking, frontend admission sealing and concurrent stop, Sirius/pipeline cleanup, and retained-state bounds. No new double release, leak, deadlock, unbounded retention, or liveness defect found.\n\nTests cover completed-error release, incomplete-owner preservation, rollback, shared-fixture reset, concurrent stop, pre-registration connections, and pipeline/runtime ordering; new synchronization uses barriers rather than sleeps. Exact-head Ubuntu race CI selected all owning packages and passed; coverage UT, SCA, shared build, and active BVTs also passed.\n\nResidual notes: local tests and claimed 100-repeat focused runs were not independently reproduced; fail-stop behavior for unclassified cleanup errors remains intentional, and the original heartbeat-timeout trigger is not changed.

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/bug Something isn't working kind/enhancement size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: embedded-cluster Close timeout permanently retains admission lease

2 participants