Repository navigation
fix(lockservice): scope backend create timeout to recovery - #26553
Conversation
PR Summary by QodoScope lockservice backend-create timeout to recovery transports
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
7b8906a to
81fdcbf
Compare
LeftHandCold
left a comment
There was a problem hiding this comment.
Deep review completed at 81fdcbf. The policy split matches the production incident path: normal Lock/Unlock, keeper, and control traffic now follow their bounded caller contexts, while active-transaction recovery and service validation retain the 500ms peer-health deadline and all transports retain the independent 5s create-queue bound. MORPC create-state ownership, cancellation, timeout races, event deduplication, metric cardinality, error classification, and config slice isolation were checked without finding a production-reachable correctness, hang, leak, or normal-business regression. Focused race tests passed for MORPC and lockservice; current effective CI checks are successful.
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed the complete diff at d2301bd after the latest main merge. No blocking correctness, concurrency, lifecycle, or observability issues found. Verified the transport-policy split, caller-bound normal traffic, fail-closed recovery/validation behavior, backend-create state ownership and late completion, config slice isolation, per-request/per-create-state metric accounting, bounded rate-limited logging, and constructor/Close cleanup. Focused repeated race tests, full MORPC and lockservice race/non-race suites, metric-v2 tests, affected-package build/vet, and dashboard compile-only validation passed. The live-Grafana dashboard tests require a local Grafana and fail identically on the clean base when it is absent.
## 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 #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: - 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]>
…gin#26553) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26547 Related: matrixorigin#26475 Nightly regression: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/30649446904/job/91275888648 ## What this PR does / why we need it: The failing 1000-thread sysbench run returned 100 lock RPC errors as backend-closed (20502). Incident metrics show the same 88/12 split across two clients in both MORPC auto-create timeouts and lockservice backend-closed errors, with no create-queue full/drop, circuit-breaker trip, pod restart, or OOM. The connection factory was delayed while the CNs were CPU saturated, so the lockservice-wide 500ms backend-create deadline expired for all callers coalesced on those two cold connections. The direct mechanism is not unique to matrixorigin#26473: the 500ms lockservice setting came from matrixorigin#23435, and a genuinely blocked factory reproduces the 100/100 failure on both the pre-matrixorigin#26473 baseline and the incident MORPC code. matrixorigin#26473 makes completion-at-the-deadline classification deterministic, which can affect the boundary, but a real factory delay beyond 500ms does not require that change. This PR: - keeps the independent 5s local create-queue admission bound on every lockservice transport; - limits the 500ms peer-health deadline to active-transaction recovery and service-validation transports, where fast failure is required; - lets normal Lock/Unlock, keeper, and control traffic follow their already-bounded caller contexts and the backend's 5s connect timeout; - preserves the independent liveness probe in recovery client configs; - classifies backend-create timeout separately from generic backend-closed in MORPC and lockservice metrics; - adds a low-cardinality distinct-create-event counter alongside the existing per-request impact counter; - emits at most one warning per create state and rate-limits the static event to one log per client per minute; - updates the RPC Grafana panel to compare affected requests with distinct create events. Deep-review hardening: - the timeout logger retains only one keyed limiter state, bounding future accidental dynamic-key growth; - failure-only diagnostic fields are placed after the pre-existing hot client state, preserving mutex/pool field offsets used by every Send; - normal traffic is tested for prompt caller cancellation while factory creation remains blocked; - wrapped create-timeout errors retain their dedicated metric classification. The regression tests construct a successful but delayed backend factory. They verify 100 coalesced callers all reproduce 20502 at 500ms, while producing 100 impact counts, one event count, one retained limiter key, and one warning. The lockservice policy test verifies normal traffic succeeds after waiting beyond 500ms, remains caller-cancellable, and recovery traffic still fails fast. Verification after rebasing onto latest main: - focused fan-out race: T=0.5s, B=30s, N=60 - focused lockservice role/cancellation race: T=1.11s, B=30s, N=27 - admission-boundary, nil-state timeout, and error-classification race: N=100 each - full `./pkg/common/morpc` race: passed - full `./pkg/lockservice` race: passed - full non-race MORPC, lockservice, and metric-v2 tests: passed - build and vet for all four modified packages: passed - hot-path benchmark, clean main vs PR: both 144 B/op and 1 alloc/op; PR 207-212 ns/op vs main 210-211 ns/op - dashboard compile-only test: passed; its live-Grafana tests require `127.0.0.1:80` and fail identically on clean HEAD when Grafana is absent
## 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]>
…gin#26553) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26547 Related: matrixorigin#26475 Nightly regression: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/30649446904/job/91275888648 ## What this PR does / why we need it: The failing 1000-thread sysbench run returned 100 lock RPC errors as backend-closed (20502). Incident metrics show the same 88/12 split across two clients in both MORPC auto-create timeouts and lockservice backend-closed errors, with no create-queue full/drop, circuit-breaker trip, pod restart, or OOM. The connection factory was delayed while the CNs were CPU saturated, so the lockservice-wide 500ms backend-create deadline expired for all callers coalesced on those two cold connections. The direct mechanism is not unique to matrixorigin#26473: the 500ms lockservice setting came from matrixorigin#23435, and a genuinely blocked factory reproduces the 100/100 failure on both the pre-matrixorigin#26473 baseline and the incident MORPC code. matrixorigin#26473 makes completion-at-the-deadline classification deterministic, which can affect the boundary, but a real factory delay beyond 500ms does not require that change. This PR: - keeps the independent 5s local create-queue admission bound on every lockservice transport; - limits the 500ms peer-health deadline to active-transaction recovery and service-validation transports, where fast failure is required; - lets normal Lock/Unlock, keeper, and control traffic follow their already-bounded caller contexts and the backend's 5s connect timeout; - preserves the independent liveness probe in recovery client configs; - classifies backend-create timeout separately from generic backend-closed in MORPC and lockservice metrics; - adds a low-cardinality distinct-create-event counter alongside the existing per-request impact counter; - emits at most one warning per create state and rate-limits the static event to one log per client per minute; - updates the RPC Grafana panel to compare affected requests with distinct create events. Deep-review hardening: - the timeout logger retains only one keyed limiter state, bounding future accidental dynamic-key growth; - failure-only diagnostic fields are placed after the pre-existing hot client state, preserving mutex/pool field offsets used by every Send; - normal traffic is tested for prompt caller cancellation while factory creation remains blocked; - wrapped create-timeout errors retain their dedicated metric classification. The regression tests construct a successful but delayed backend factory. They verify 100 coalesced callers all reproduce 20502 at 500ms, while producing 100 impact counts, one event count, one retained limiter key, and one warning. The lockservice policy test verifies normal traffic succeeds after waiting beyond 500ms, remains caller-cancellable, and recovery traffic still fails fast. Verification after rebasing onto latest main: - focused fan-out race: T=0.5s, B=30s, N=60 - focused lockservice role/cancellation race: T=1.11s, B=30s, N=27 - admission-boundary, nil-state timeout, and error-classification race: N=100 each - full `./pkg/common/morpc` race: passed - full `./pkg/lockservice` race: passed - full non-race MORPC, lockservice, and metric-v2 tests: passed - build and vet for all four modified packages: passed - hot-path benchmark, clean main vs PR: both 144 B/op and 1 alloc/op; PR 207-212 ns/op vs main 210-211 ns/op - dashboard compile-only test: passed; its live-Grafana tests require `127.0.0.1:80` and fail identically on clean HEAD when Grafana is absent
## 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]>
…gin#26553) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26547 Related: matrixorigin#26475 Nightly regression: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/30649446904/job/91275888648 ## What this PR does / why we need it: The failing 1000-thread sysbench run returned 100 lock RPC errors as backend-closed (20502). Incident metrics show the same 88/12 split across two clients in both MORPC auto-create timeouts and lockservice backend-closed errors, with no create-queue full/drop, circuit-breaker trip, pod restart, or OOM. The connection factory was delayed while the CNs were CPU saturated, so the lockservice-wide 500ms backend-create deadline expired for all callers coalesced on those two cold connections. The direct mechanism is not unique to matrixorigin#26473: the 500ms lockservice setting came from matrixorigin#23435, and a genuinely blocked factory reproduces the 100/100 failure on both the pre-matrixorigin#26473 baseline and the incident MORPC code. matrixorigin#26473 makes completion-at-the-deadline classification deterministic, which can affect the boundary, but a real factory delay beyond 500ms does not require that change. This PR: - keeps the independent 5s local create-queue admission bound on every lockservice transport; - limits the 500ms peer-health deadline to active-transaction recovery and service-validation transports, where fast failure is required; - lets normal Lock/Unlock, keeper, and control traffic follow their already-bounded caller contexts and the backend's 5s connect timeout; - preserves the independent liveness probe in recovery client configs; - classifies backend-create timeout separately from generic backend-closed in MORPC and lockservice metrics; - adds a low-cardinality distinct-create-event counter alongside the existing per-request impact counter; - emits at most one warning per create state and rate-limits the static event to one log per client per minute; - updates the RPC Grafana panel to compare affected requests with distinct create events. Deep-review hardening: - the timeout logger retains only one keyed limiter state, bounding future accidental dynamic-key growth; - failure-only diagnostic fields are placed after the pre-existing hot client state, preserving mutex/pool field offsets used by every Send; - normal traffic is tested for prompt caller cancellation while factory creation remains blocked; - wrapped create-timeout errors retain their dedicated metric classification. The regression tests construct a successful but delayed backend factory. They verify 100 coalesced callers all reproduce 20502 at 500ms, while producing 100 impact counts, one event count, one retained limiter key, and one warning. The lockservice policy test verifies normal traffic succeeds after waiting beyond 500ms, remains caller-cancellable, and recovery traffic still fails fast. Verification after rebasing onto latest main: - focused fan-out race: T=0.5s, B=30s, N=60 - focused lockservice role/cancellation race: T=1.11s, B=30s, N=27 - admission-boundary, nil-state timeout, and error-classification race: N=100 each - full `./pkg/common/morpc` race: passed - full `./pkg/lockservice` race: passed - full non-race MORPC, lockservice, and metric-v2 tests: passed - build and vet for all four modified packages: passed - hot-path benchmark, clean main vs PR: both 144 B/op and 1 alloc/op; PR 207-212 ns/op vs main 210-211 ns/op - dashboard compile-only test: passed; its live-Grafana tests require `127.0.0.1:80` and fail identically on clean HEAD when Grafana is absent
## 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]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26547
Related: #26475
Nightly regression: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/30649446904/job/91275888648
What this PR does / why we need it:
The failing 1000-thread sysbench run returned 100 lock RPC errors as backend-closed (20502). Incident metrics show the same 88/12 split across two clients in both MORPC auto-create timeouts and lockservice backend-closed errors, with no create-queue full/drop, circuit-breaker trip, pod restart, or OOM. The connection factory was delayed while the CNs were CPU saturated, so the lockservice-wide 500ms backend-create deadline expired for all callers coalesced on those two cold connections.
The direct mechanism is not unique to #26473: the 500ms lockservice setting came from #23435, and a genuinely blocked factory reproduces the 100/100 failure on both the pre-#26473 baseline and the incident MORPC code. #26473 makes completion-at-the-deadline classification deterministic, which can affect the boundary, but a real factory delay beyond 500ms does not require that change.
This PR:
Deep-review hardening:
The regression tests construct a successful but delayed backend factory. They verify 100 coalesced callers all reproduce 20502 at 500ms, while producing 100 impact counts, one event count, one retained limiter key, and one warning. The lockservice policy test verifies normal traffic succeeds after waiting beyond 500ms, remains caller-cancellable, and recovery traffic still fails fast.
Verification after rebasing onto latest main:
./pkg/common/morpcrace: passed./pkg/lockservicerace: passed127.0.0.1:80and fail identically on clean HEAD when Grafana is absent