Repository navigation
Description
Is there an existing issue for the same bug?
- Related closed issue: [Bug]: pkg/embed cluster cleanup can return bad connection and poison remaining tests #27072 (
pkg/embedcleanup error retains cluster admission and poisons later tests). - Related closed issue: [Bug]: pkg/embed TestBasicCluster can hang until the Ubuntu race UT deadline #27073 (embedded-cluster UT non-termination under Ubuntu race load).
- This issue records a current-main recurrence with a different terminal trigger: CN final view-metadata withdrawal times out, after which
Closecannot make progress or release admission.
Environment and exact evidence
- Repository:
matrixorigin/matrixone - PR head:
37f9b96438a5d38ae7f34294236d435e8554a0cc(PR fix: support prepared TIME numeric arithmetic #29036) - Base:
8e8e1998ef02b1f6233ddb1c2d3208f3b70d2d83 - Workflow run: https://github.com/matrixorigin/matrixone/actions/runs/35182724833
- Failed job: https://github.com/matrixorigin/matrixone/actions/runs/35182724833/job/105078226716
- Diagnostic artifact: https://github.com/matrixorigin/matrixone/actions/runs/35182724833/artifacts/10482098339
- Runner: Ubuntu/x86, Go 1.26.4, race UT workload
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:
cnservice.service.Closeis guarded bysync.Once, so a withdrawal error is cached and a later retry cannot re-run the close sequence.closeCNServiceStepsreturns the withdrawal error even though earlier local shutdown steps may already have completed.pkg/embedstops 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.- The resulting state is neither safely retryable nor fully released: the admission lease and service dependencies remain owned, while another
Closecannot 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
fix: release embedded cluster ownership after terminal cleanup (#29048)