Skip to content

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

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

Environment and exact evidence

Actual behavior

The first failure is pkg/tests/issues/isolated/TestAutoIDCacheRestartAndDisabledNode.
During the second cluster restart, CN shutdown reports:

failed to publish final view metadata withdrawal
clean_handoff=false
error=context deadline exceeded

The cluster setup record then shows:

service-close ... status=error admission_released=false

The test cleanup calls Close again, but it returns the same cached error immediately. The complete-cluster admission lease remains held. Five later tests fail only because they cannot acquire a cluster:

invalid state another complete test cluster is already active in this process

The failed tests are TestHashBuildSharedBudgetRecoverySQL, TestIssue25782BroadcastHashBuildFailsClosedUnderHardBudget, TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges, TestIssue27719DropAccountCleansSQLTaskLifecycle, and TestSpeedupAbortAllTxn.

Root cause

The cleanup state machine conflates local service teardown with the remote metadata-withdrawal handshake:

  1. cnservice.service.Close is guarded by sync.Once, so a withdrawal error is cached and a later retry cannot re-run the close sequence.
  2. closeCNServiceSteps returns the withdrawal error even though earlier local shutdown steps may already have completed.
  3. pkg/embed stops walking the service list on the first service close error and only releases the process-wide cluster admission lease when the whole close returns nil.
  4. The resulting state is neither safely retryable nor fully released: the admission lease and service dependencies remain owned, while another Close cannot make progress.

This is a general lifecycle bug. Any transient error in a service close path can poison the process-wide embedded-cluster admission and turn one test failure into a cascade of unrelated failures.

Expected behavior

Cluster shutdown needs an explicit two-part contract:

  • local owners must reach an idempotent terminal cleanup state or a demonstrably retryable state;
  • the process-wide admission lease must be released only after the local ownership decision is complete, without making a cached remote handoff error permanently block cleanup.

The fix should preserve the safety requirement that TN/WAL dependencies remain alive while accepted work still needs them, while making the withdrawal/cleanup error path retryable and preventing admission poisoning.

The separate pkg/proxy/TestClientConnHandshakePhases/TLS_request_then_final_login failure in the same CI run is unrelated and should not be folded into this issue.

Activity

  1. self-assigned this
    on Sep 17, 2026
  2. added
    kind/bug
    on Sep 17, 2026
  3. added a commit that references this issue on Sep 17, 2026
    24e66eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions