Repository navigation
fix(logservice): retry transient HAKeeper backend closures - #28453
Conversation
MORPC can report a failed HAKeeper transport generation as ErrBackendClosed instead of EOF. Treat connection-generation failures as retryable within the caller deadline, while preserving terminal managed-client shutdown semantics so an in-flight close cannot recreate the transport.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 6232b85 against base bd8801a: no confirmed blocking regression found. COMMENT only, per the self-authored-PR instruction and explicit CI override.
Read both changed files and traced retry consumers, generation replacement, allocator/refill ownership, HAKeeper state-machine allocation, MORPC request/future cleanup and transport Close. The added backend/connect/admission/reset errors enter the existing retry loops; caller cancellation/deadline and business errors remain non-retryable. The existing 10 ms timer is stopped on exit and selects the caller context, with no additional nested retry owner added to GetScheduleCommands. Public request entry points validate a deadline. Transport reset remains generation-scoped, so a late failure cannot retire a newer client. This extends transport retries, not a promise that physical teardown or waiting for an existing mutex owner is interruptible by the waiting caller's context.
Close publishes the terminal transport state before detaching the client and holds the managed lock through inner cleanup. Concurrent/repeated callers observe the same cleanup result; prepareClientLocked rejects recreation after Close and getCurrentClient hides the detached transport. MORPC closes/cancels backend workers without a discovered reverse dependency on the managed lock. The change does not invalidate previously reserved local ID cache entries; its terminal guarantee is transport admission/recreation, not a newly enforced rejection on every cache-only allocation.
Lost allocation responses can consume an unused range on retry, as with the existing EOF path. The server's monotonic allocation state prevents this from turning into duplicate returned ranges; the request-ID variant keeps its stable request identity and server-side deduplication. Other affected state-update retries retain the existing method payloads and error behavior rather than introducing a new transaction identity. No new persistent map, background goroutine or retry queue is added. Existing future.Close/response.Release, refill-channel publication and executor/transport owners retain cleanup responsibility; failed closes remain reported through the existing logging path or the joined Close result. No new high-cardinality metric or per-attempt log stream is introduced.
Independent focused evidence: extracted this head's exact managed Close/getCurrentClient methods into a standard-library-only harness with a controllable inner transport. go test -race -count=100 passed with 32 concurrent Close callers, one cleanup invocation, cleanup-error convergence, terminal transport visibility and empty-client Close. This is a focused state-machine probe, not the complete native logservice package or an end-to-end transport-recovery run. I also inspected the added retry/deadline/in-flight-close tests and their hooks; the author reports focused race repetition and package/issue tests, with the unrelated listener-collision test explicitly excluded.
At the single snapshot, exact-head MatrixOne ALL CI run 34300098985 was in progress. Pending CI is not counted as green. Per override, no CI polling/waiting and no repository source changes.
…gin#28453) ## Summary HAKeeper can report a failed MORPC transport generation as `ErrBackendClosed` instead of EOF. The managed client previously reset that generation but returned the error directly, so a transient control-plane disconnect escaped as a SQL failure during `TestIssue26640CrossAccountRestoreRebindsPrivileges`. This change: - retries the transport-generation errors (`ErrBackendClosed`, connect/admission failures, connection reset) through the caller's existing deadline; - makes `managedHAKeeperClient.Close` terminal, prevents late failures from recreating a transport, and makes concurrent `Close` calls join the same cleanup result; - consolidates the retry regressions into deterministic table-driven tests, including deadline, business-error, in-flight-close, and concurrent-close cases. The retry is bounded by every public HAKeeper request context. An allocation whose response is lost may consume an ID range, as the existing EOF retry already did, but the server's monotonic allocator prevents duplicate IDs from being returned. ## Root cause and scope - matrixorigin#28443 failed before its restore/privilege assertions. The embedded LogService first reported checker/raft timing pressure, then MORPC returned `backend connection closed` while allocating an ID. The failure was a downstream control-plane transport error; the deeper first scheduler/WAL/IO fault is not proven by that job. - matrixorigin#28447 is a separate MORPC stream-sequence-gap failure. It was already fixed by merged matrixorigin#28358, which is in this branch's base. The exact regression test passes repeatedly on current main, so this PR intentionally does not duplicate that dispatch implementation. Fixes matrixorigin#28452 Related: matrixorigin#28443, matrixorigin#28447, matrixorigin#28313, matrixorigin#28358 ## Validation - `TestIssue26640CrossAccountRestoreRebindsPrivileges`: `-count=3`, passed. - `TestIssue28313EmptyRemoteDispatch`: `-count=5`, passed. - HAKeeper retry/close focused tests: normal and `-race -count=100`, passed. - `pkg/logservice`: normal and race package runs passed with the known unrelated flaky `TestNewServiceClosesStoreOnReplicaStartFailure` excluded; that test still fails independently with listener address collisions/store-close leakage. - `go vet ./pkg/logservice` with the repository CGo flags and `git diff --check`, passed. ## CI triage for run 34300098985 The source changes in this PR are limited to pkg/logservice. In the exact-head CI run: - Shared build, SCA, normal UT, Compose BVT, and Standalone BVT passed. - The UT coverage producer failed only at the unrelated existing test pkg/sql/compile/TestIssue27261StopSendingDuringParallelReaderBuildStaysGraceful, which returned context canceled; the producer report recorded no build failures and two failed events in pkg/sql/compile. - The downstream coverage merge failed because the required UT producer artifact was incomplete (prerequisites_ready=false); it did not calculate a coverage verdict. - The same TestIssue27261 test passed locally 10 times, and the PR retry/close focused tests passed locally 20 times normally and 100 times under -race; go vet and git diff --check passed. No unrelated compile/pipeline change is included to mask this flaky coverage-only failure. This PR was not rebased and the existing PR base was not changed.
…gin#28453) ## Summary HAKeeper can report a failed MORPC transport generation as `ErrBackendClosed` instead of EOF. The managed client previously reset that generation but returned the error directly, so a transient control-plane disconnect escaped as a SQL failure during `TestIssue26640CrossAccountRestoreRebindsPrivileges`. This change: - retries the transport-generation errors (`ErrBackendClosed`, connect/admission failures, connection reset) through the caller's existing deadline; - makes `managedHAKeeperClient.Close` terminal, prevents late failures from recreating a transport, and makes concurrent `Close` calls join the same cleanup result; - consolidates the retry regressions into deterministic table-driven tests, including deadline, business-error, in-flight-close, and concurrent-close cases. The retry is bounded by every public HAKeeper request context. An allocation whose response is lost may consume an ID range, as the existing EOF retry already did, but the server's monotonic allocator prevents duplicate IDs from being returned. ## Root cause and scope - matrixorigin#28443 failed before its restore/privilege assertions. The embedded LogService first reported checker/raft timing pressure, then MORPC returned `backend connection closed` while allocating an ID. The failure was a downstream control-plane transport error; the deeper first scheduler/WAL/IO fault is not proven by that job. - matrixorigin#28447 is a separate MORPC stream-sequence-gap failure. It was already fixed by merged matrixorigin#28358, which is in this branch's base. The exact regression test passes repeatedly on current main, so this PR intentionally does not duplicate that dispatch implementation. Fixes matrixorigin#28452 Related: matrixorigin#28443, matrixorigin#28447, matrixorigin#28313, matrixorigin#28358 ## Validation - `TestIssue26640CrossAccountRestoreRebindsPrivileges`: `-count=3`, passed. - `TestIssue28313EmptyRemoteDispatch`: `-count=5`, passed. - HAKeeper retry/close focused tests: normal and `-race -count=100`, passed. - `pkg/logservice`: normal and race package runs passed with the known unrelated flaky `TestNewServiceClosesStoreOnReplicaStartFailure` excluded; that test still fails independently with listener address collisions/store-close leakage. - `go vet ./pkg/logservice` with the repository CGo flags and `git diff --check`, passed. ## CI triage for run 34300098985 The source changes in this PR are limited to pkg/logservice. In the exact-head CI run: - Shared build, SCA, normal UT, Compose BVT, and Standalone BVT passed. - The UT coverage producer failed only at the unrelated existing test pkg/sql/compile/TestIssue27261StopSendingDuringParallelReaderBuildStaysGraceful, which returned context canceled; the producer report recorded no build failures and two failed events in pkg/sql/compile. - The downstream coverage merge failed because the required UT producer artifact was incomplete (prerequisites_ready=false); it did not calculate a coverage verdict. - The same TestIssue27261 test passed locally 10 times, and the PR retry/close focused tests passed locally 20 times normally and 100 times under -race; go vet and git diff --check passed. No unrelated compile/pipeline change is included to mask this flaky coverage-only failure. This PR was not rebased and the existing PR base was not changed.
…gin#28453) ## Summary HAKeeper can report a failed MORPC transport generation as `ErrBackendClosed` instead of EOF. The managed client previously reset that generation but returned the error directly, so a transient control-plane disconnect escaped as a SQL failure during `TestIssue26640CrossAccountRestoreRebindsPrivileges`. This change: - retries the transport-generation errors (`ErrBackendClosed`, connect/admission failures, connection reset) through the caller's existing deadline; - makes `managedHAKeeperClient.Close` terminal, prevents late failures from recreating a transport, and makes concurrent `Close` calls join the same cleanup result; - consolidates the retry regressions into deterministic table-driven tests, including deadline, business-error, in-flight-close, and concurrent-close cases. The retry is bounded by every public HAKeeper request context. An allocation whose response is lost may consume an ID range, as the existing EOF retry already did, but the server's monotonic allocator prevents duplicate IDs from being returned. ## Root cause and scope - matrixorigin#28443 failed before its restore/privilege assertions. The embedded LogService first reported checker/raft timing pressure, then MORPC returned `backend connection closed` while allocating an ID. The failure was a downstream control-plane transport error; the deeper first scheduler/WAL/IO fault is not proven by that job. - matrixorigin#28447 is a separate MORPC stream-sequence-gap failure. It was already fixed by merged matrixorigin#28358, which is in this branch's base. The exact regression test passes repeatedly on current main, so this PR intentionally does not duplicate that dispatch implementation. Fixes matrixorigin#28452 Related: matrixorigin#28443, matrixorigin#28447, matrixorigin#28313, matrixorigin#28358 ## Validation - `TestIssue26640CrossAccountRestoreRebindsPrivileges`: `-count=3`, passed. - `TestIssue28313EmptyRemoteDispatch`: `-count=5`, passed. - HAKeeper retry/close focused tests: normal and `-race -count=100`, passed. - `pkg/logservice`: normal and race package runs passed with the known unrelated flaky `TestNewServiceClosesStoreOnReplicaStartFailure` excluded; that test still fails independently with listener address collisions/store-close leakage. - `go vet ./pkg/logservice` with the repository CGo flags and `git diff --check`, passed. ## CI triage for run 34300098985 The source changes in this PR are limited to pkg/logservice. In the exact-head CI run: - Shared build, SCA, normal UT, Compose BVT, and Standalone BVT passed. - The UT coverage producer failed only at the unrelated existing test pkg/sql/compile/TestIssue27261StopSendingDuringParallelReaderBuildStaysGraceful, which returned context canceled; the producer report recorded no build failures and two failed events in pkg/sql/compile. - The downstream coverage merge failed because the required UT producer artifact was incomplete (prerequisites_ready=false); it did not calculate a coverage verdict. - The same TestIssue27261 test passed locally 10 times, and the PR retry/close focused tests passed locally 20 times normally and 100 times under -race; go vet and git diff --check passed. No unrelated compile/pipeline change is included to mask this flaky coverage-only failure. This PR was not rebased and the existing PR base was not changed.
Summary
HAKeeper can report a failed MORPC transport generation as
ErrBackendClosedinstead of EOF. The managed client previously reset that generation but returned the error directly, so a transient control-plane disconnect escaped as a SQL failure duringTestIssue26640CrossAccountRestoreRebindsPrivileges.This change:
ErrBackendClosed, connect/admission failures, connection reset) through the caller's existing deadline;managedHAKeeperClient.Closeterminal, prevents late failures from recreating a transport, and makes concurrentClosecalls join the same cleanup result;The retry is bounded by every public HAKeeper request context. An allocation whose response is lost may consume an ID range, as the existing EOF retry already did, but the server's monotonic allocator prevents duplicate IDs from being returned.
Root cause and scope
backend connection closedwhile allocating an ID. The failure was a downstream control-plane transport error; the deeper first scheduler/WAL/IO fault is not proven by that job.Fixes #28452
Related: #28443, #28447, #28313, #28358
Validation
TestIssue26640CrossAccountRestoreRebindsPrivileges:-count=3, passed.TestIssue28313EmptyRemoteDispatch:-count=5, passed.-race -count=100, passed.pkg/logservice: normal and race package runs passed with the known unrelated flakyTestNewServiceClosesStoreOnReplicaStartFailureexcluded; that test still fails independently with listener address collisions/store-close leakage.go vet ./pkg/logservicewith the repository CGo flags andgit diff --check, passed.CI triage for run 34300098985
The source changes in this PR are limited to pkg/logservice. In the exact-head CI run:
No unrelated compile/pipeline change is included to mask this flaky coverage-only failure. This PR was not rebased and the existing PR base was not changed.