Repository navigation
test(lockservice): harden test topology cleanup - #26555
Conversation
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.
Re-reviewed the complete diff at ec6b0db. The previous blockers are closed: cleanup ownership is registered before construction/callback failure points, every constructed service is attempted before allocator/cluster/socket-directory teardown, cleanup errors are joined, and callback panics are preserved. All lockservice timestamp-based Unix socket helpers are now isolated with MkdirTemp; the original backend-create timeout fix remains correctly attributed to #26553.
Unhappy-path audit (Q1/Q2/Q3): no unowned resource, unbounded wait, or skipped later cleanup remains in the changed paths. This is test-only code, so there is no production/non-spill performance cost.
Fresh local verification:
- focused cleanup/socket/RPC tests: pass
- the same focused set under -race, count=3: pass
- full ./pkg/lockservice, count=1: pass (102.5s)
Approving this head.
Merge Queue Status
This pull request spent 9 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Revalidated the merge-updated head 500a838. This commit is a clean merge of main into the previously approved ec6b0db head: the current PR diff is still exactly the same four lockservice test files, and there is no merge delta at all in those PR-owned files. The cleanup ownership/order, panic preservation, partial-construction handling, and MkdirTemp socket isolation therefore remain unchanged.
Fresh focused cleanup/socket/RPC tests passed at count=3 against the merged dependencies. Approval stands for this exact head; the newly triggered required CI jobs are still running.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #26575 ## What this PR does / why we need it: ### Root cause Lockservice active-transaction recovery intentionally uses a separate MORPC client with a 500ms backend-create budget. The failing CI log shows that cold connection timing out after 500.241548ms. Production correctly treats that observation as indeterminate: it retains the transaction and retries during a later timeout scan. `TestCheckTxnTimeout` instead required the transaction to be removed by one scan, so scheduler delay in a valid recovery path failed the test. At the failing commit, that assertion also exited the topology callback before the service and allocator cleanup statements. Their RPC goroutines remained active and caused the later `TestIssue5176` and `TestUnlockInRollingRestartCN` leak reports; the latter test's log contains the previous test's service ID. Main has since merged #26555, which installs the topology cleanup before the callback and closes it from a defer. This PR does not duplicate that already-merged cleanup fix. ### Changes - Make `TestCheckTxnTimeout` assert the production contract: an indeterminate scan may retain the transaction, but subsequent scans must eventually remove it after authoritative inactive and cannot-commit fence results. - Exercise the exact observed `morpc.ErrBackendCreateTimeout` in the existing deterministic error-then-confirmed-inactive unit test. The 500ms recovery policy remains unchanged. There are no production-code, API, wire-format, or performance changes. ### Verification Environment: Go 1.26.4, Darwin/arm64, controlled MatrixOne CGo test wrapper. - Original three tests in order, non-race, `-count=10`: pass - `TestValidTxnCheckErrorThenConfirmedInactive`, non-race, `-count=100`: pass - Adaptive focused race stress (30s budget per test): - `TestCheckTxnTimeout`: T=1.16s, N=25 - `TestValidTxnCheckErrorThenConfirmedInactive`: T=0s, N=100 - `TestIssue5176`: T=0.09s, N=100 - `TestUnlockInRollingRestartCN`: T=2.08s, N=14 - Full `./pkg/lockservice`, non-race: pass (113.574s) - Full `./pkg/lockservice`, race: pass (121.847s) - `go list`, `go build`, and `go vet` for `./pkg/lockservice`: pass BVT is not applicable because the affected contract is an internal Go recovery scanner and test-topology lifecycle, with no SQL-visible behavior. ### Residual risk The test retains its existing 10s outer bound and still fails if recovery never obtains an authoritative result. It only permits the transient first-scan timeout that production explicitly handles by retrying. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR relates to: Related to matrixorigin#26551 ## What this PR does / why we need it: The observed lock RPC deadline in matrixorigin#26551 was fixed directly by matrixorigin#26553, which scopes the backend-create timeout to recovery. This follow-up hardens the test topology against two independent failure modes exposed during that investigation: Unix socket collisions and incomplete cleanup after a callback failure. This change: - migrates every lockservice test helper away from `time.Now().Nanosecond()` socket names to an OS-allocated `/tmp/mo-lockservice-*` directory; - places the allocator and service sockets under that exclusive directory with short deterministic file names; - installs cleanup ownership before invoking the callback, including partially constructed topologies; - closes every service, allocator, cluster, and socket directory even if an earlier close fails or the callback panics; and - adds regressions for cleanup ordering, partial construction, panic handling, directory isolation, and the mainline timeout policy. Validation: - `go build ./pkg/lockservice` - `go vet ./pkg/lockservice` - `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` - focused cleanup and socket isolation race tests, 100 repetitions each - `TestNewTxnLockInRollingRestartCN` under race, 10 repetitions - `TestLockserviceBackendCreateTimeoutPolicy` under race, 100 repetitions - `TestAutoCreateDeadlineRejectsLateSuccessfulBackend` under race, 100 repetitions - full `pkg/lockservice` tests, with and without race detection --------- Co-authored-by: XuPeng-SH <[email protected]>
…in#26587) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26575 ## What this PR does / why we need it: ### Root cause Lockservice active-transaction recovery intentionally uses a separate MORPC client with a 500ms backend-create budget. The failing CI log shows that cold connection timing out after 500.241548ms. Production correctly treats that observation as indeterminate: it retains the transaction and retries during a later timeout scan. `TestCheckTxnTimeout` instead required the transaction to be removed by one scan, so scheduler delay in a valid recovery path failed the test. At the failing commit, that assertion also exited the topology callback before the service and allocator cleanup statements. Their RPC goroutines remained active and caused the later `TestIssue5176` and `TestUnlockInRollingRestartCN` leak reports; the latter test's log contains the previous test's service ID. Main has since merged matrixorigin#26555, which installs the topology cleanup before the callback and closes it from a defer. This PR does not duplicate that already-merged cleanup fix. ### Changes - Make `TestCheckTxnTimeout` assert the production contract: an indeterminate scan may retain the transaction, but subsequent scans must eventually remove it after authoritative inactive and cannot-commit fence results. - Exercise the exact observed `morpc.ErrBackendCreateTimeout` in the existing deterministic error-then-confirmed-inactive unit test. The 500ms recovery policy remains unchanged. There are no production-code, API, wire-format, or performance changes. ### Verification Environment: Go 1.26.4, Darwin/arm64, controlled MatrixOne CGo test wrapper. - Original three tests in order, non-race, `-count=10`: pass - `TestValidTxnCheckErrorThenConfirmedInactive`, non-race, `-count=100`: pass - Adaptive focused race stress (30s budget per test): - `TestCheckTxnTimeout`: T=1.16s, N=25 - `TestValidTxnCheckErrorThenConfirmedInactive`: T=0s, N=100 - `TestIssue5176`: T=0.09s, N=100 - `TestUnlockInRollingRestartCN`: T=2.08s, N=14 - Full `./pkg/lockservice`, non-race: pass (113.574s) - Full `./pkg/lockservice`, race: pass (121.847s) - `go list`, `go build`, and `go vet` for `./pkg/lockservice`: pass BVT is not applicable because the affected contract is an internal Go recovery scanner and test-topology lifecycle, with no SQL-visible behavior. ### Residual risk The test retains its existing 10s outer bound and still fails if recovery never obtains an authoritative result. It only permits the transient first-scan timeout that production explicitly handles by retrying. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR relates to: Related to matrixorigin#26551 ## What this PR does / why we need it: The observed lock RPC deadline in matrixorigin#26551 was fixed directly by matrixorigin#26553, which scopes the backend-create timeout to recovery. This follow-up hardens the test topology against two independent failure modes exposed during that investigation: Unix socket collisions and incomplete cleanup after a callback failure. This change: - migrates every lockservice test helper away from `time.Now().Nanosecond()` socket names to an OS-allocated `/tmp/mo-lockservice-*` directory; - places the allocator and service sockets under that exclusive directory with short deterministic file names; - installs cleanup ownership before invoking the callback, including partially constructed topologies; - closes every service, allocator, cluster, and socket directory even if an earlier close fails or the callback panics; and - adds regressions for cleanup ordering, partial construction, panic handling, directory isolation, and the mainline timeout policy. Validation: - `go build ./pkg/lockservice` - `go vet ./pkg/lockservice` - `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` - focused cleanup and socket isolation race tests, 100 repetitions each - `TestNewTxnLockInRollingRestartCN` under race, 10 repetitions - `TestLockserviceBackendCreateTimeoutPolicy` under race, 100 repetitions - `TestAutoCreateDeadlineRejectsLateSuccessfulBackend` under race, 100 repetitions - full `pkg/lockservice` tests, with and without race detection --------- Co-authored-by: XuPeng-SH <[email protected]>
…in#26587) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26575 ## What this PR does / why we need it: ### Root cause Lockservice active-transaction recovery intentionally uses a separate MORPC client with a 500ms backend-create budget. The failing CI log shows that cold connection timing out after 500.241548ms. Production correctly treats that observation as indeterminate: it retains the transaction and retries during a later timeout scan. `TestCheckTxnTimeout` instead required the transaction to be removed by one scan, so scheduler delay in a valid recovery path failed the test. At the failing commit, that assertion also exited the topology callback before the service and allocator cleanup statements. Their RPC goroutines remained active and caused the later `TestIssue5176` and `TestUnlockInRollingRestartCN` leak reports; the latter test's log contains the previous test's service ID. Main has since merged matrixorigin#26555, which installs the topology cleanup before the callback and closes it from a defer. This PR does not duplicate that already-merged cleanup fix. ### Changes - Make `TestCheckTxnTimeout` assert the production contract: an indeterminate scan may retain the transaction, but subsequent scans must eventually remove it after authoritative inactive and cannot-commit fence results. - Exercise the exact observed `morpc.ErrBackendCreateTimeout` in the existing deterministic error-then-confirmed-inactive unit test. The 500ms recovery policy remains unchanged. There are no production-code, API, wire-format, or performance changes. ### Verification Environment: Go 1.26.4, Darwin/arm64, controlled MatrixOne CGo test wrapper. - Original three tests in order, non-race, `-count=10`: pass - `TestValidTxnCheckErrorThenConfirmedInactive`, non-race, `-count=100`: pass - Adaptive focused race stress (30s budget per test): - `TestCheckTxnTimeout`: T=1.16s, N=25 - `TestValidTxnCheckErrorThenConfirmedInactive`: T=0s, N=100 - `TestIssue5176`: T=0.09s, N=100 - `TestUnlockInRollingRestartCN`: T=2.08s, N=14 - Full `./pkg/lockservice`, non-race: pass (113.574s) - Full `./pkg/lockservice`, race: pass (121.847s) - `go list`, `go build`, and `go vet` for `./pkg/lockservice`: pass BVT is not applicable because the affected contract is an internal Go recovery scanner and test-topology lifecycle, with no SQL-visible behavior. ### Residual risk The test retains its existing 10s outer bound and still fails if recovery never obtains an authoritative result. It only permits the transient first-scan timeout that production explicitly handles by retrying. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR relates to: Related to matrixorigin#26551 ## What this PR does / why we need it: The observed lock RPC deadline in matrixorigin#26551 was fixed directly by matrixorigin#26553, which scopes the backend-create timeout to recovery. This follow-up hardens the test topology against two independent failure modes exposed during that investigation: Unix socket collisions and incomplete cleanup after a callback failure. This change: - migrates every lockservice test helper away from `time.Now().Nanosecond()` socket names to an OS-allocated `/tmp/mo-lockservice-*` directory; - places the allocator and service sockets under that exclusive directory with short deterministic file names; - installs cleanup ownership before invoking the callback, including partially constructed topologies; - closes every service, allocator, cluster, and socket directory even if an earlier close fails or the callback panics; and - adds regressions for cleanup ordering, partial construction, panic handling, directory isolation, and the mainline timeout policy. Validation: - `go build ./pkg/lockservice` - `go vet ./pkg/lockservice` - `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` - focused cleanup and socket isolation race tests, 100 repetitions each - `TestNewTxnLockInRollingRestartCN` under race, 10 repetitions - `TestLockserviceBackendCreateTimeoutPolicy` under race, 100 repetitions - `TestAutoCreateDeadlineRejectsLateSuccessfulBackend` under race, 100 repetitions - full `pkg/lockservice` tests, with and without race detection --------- Co-authored-by: XuPeng-SH <[email protected]>
…in#26587) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26575 ## What this PR does / why we need it: ### Root cause Lockservice active-transaction recovery intentionally uses a separate MORPC client with a 500ms backend-create budget. The failing CI log shows that cold connection timing out after 500.241548ms. Production correctly treats that observation as indeterminate: it retains the transaction and retries during a later timeout scan. `TestCheckTxnTimeout` instead required the transaction to be removed by one scan, so scheduler delay in a valid recovery path failed the test. At the failing commit, that assertion also exited the topology callback before the service and allocator cleanup statements. Their RPC goroutines remained active and caused the later `TestIssue5176` and `TestUnlockInRollingRestartCN` leak reports; the latter test's log contains the previous test's service ID. Main has since merged matrixorigin#26555, which installs the topology cleanup before the callback and closes it from a defer. This PR does not duplicate that already-merged cleanup fix. ### Changes - Make `TestCheckTxnTimeout` assert the production contract: an indeterminate scan may retain the transaction, but subsequent scans must eventually remove it after authoritative inactive and cannot-commit fence results. - Exercise the exact observed `morpc.ErrBackendCreateTimeout` in the existing deterministic error-then-confirmed-inactive unit test. The 500ms recovery policy remains unchanged. There are no production-code, API, wire-format, or performance changes. ### Verification Environment: Go 1.26.4, Darwin/arm64, controlled MatrixOne CGo test wrapper. - Original three tests in order, non-race, `-count=10`: pass - `TestValidTxnCheckErrorThenConfirmedInactive`, non-race, `-count=100`: pass - Adaptive focused race stress (30s budget per test): - `TestCheckTxnTimeout`: T=1.16s, N=25 - `TestValidTxnCheckErrorThenConfirmedInactive`: T=0s, N=100 - `TestIssue5176`: T=0.09s, N=100 - `TestUnlockInRollingRestartCN`: T=2.08s, N=14 - Full `./pkg/lockservice`, non-race: pass (113.574s) - Full `./pkg/lockservice`, race: pass (121.847s) - `go list`, `go build`, and `go vet` for `./pkg/lockservice`: pass BVT is not applicable because the affected contract is an internal Go recovery scanner and test-topology lifecycle, with no SQL-visible behavior. ### Residual risk The test retains its existing 10s outer bound and still fails if recovery never obtains an authoritative result. It only permits the transient first-scan timeout that production explicitly handles by retrying. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR relates to:
Related to #26551
What this PR does / why we need it:
The observed lock RPC deadline in #26551 was fixed directly by #26553, which
scopes the backend-create timeout to recovery. This follow-up hardens the test
topology against two independent failure modes exposed during that investigation:
Unix socket collisions and incomplete cleanup after a callback failure.
This change:
time.Now().Nanosecond()socket names to an OS-allocated
/tmp/mo-lockservice-*directory;short deterministic file names;
constructed topologies;
earlier close fails or the callback panics; and
directory isolation, and the mainline timeout policy.
Validation:
go build ./pkg/lockservicego vet ./pkg/lockservicegolangci-lint run -c .golangci.yml ./pkg/lockservice/...TestNewTxnLockInRollingRestartCNunder race, 10 repetitionsTestLockserviceBackendCreateTimeoutPolicyunder race, 100 repetitionsTestAutoCreateDeadlineRejectsLateSuccessfulBackendunder race, 100 repetitionspkg/lockservicetests, with and without race detection