Repository navigation
fix(lockservice): batch multi-table remote unlocks - #27653
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? |
aptend
left a comment
There was a problem hiding this comment.
Reviewed exact head 8c483d7. Deep-reviewed the v30 capability handshake, bounded per-owner partitioning, owner-side generation validation and closure admission, partial/retry fallback, bind-ref/ledger finalization, protobuf/RPC routing, and the complete diff.
Validation: all five changed/new focused tests passed under race 100x each; the full pkg/lockservice suite passed both normally and under -race; go vet passed for pkg/lockservice and pkg/pb/lock; the fixed-count multi-table benchmark and protobuf package build passed.
|
Tick the box to add this pull request to the merge queue (same as
|
## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27628 ## What this PR does / why we need it: The table-scoped remote-unlock correctness work after matrixorigin#26706 made every table on the same physical lock owner repeat the full transaction-closure lifecycle: one RPC, closure admission, active-generation lock, async-operation drain, bind validation, unlock, and ledger update. Under concurrent multi-table transactions this amplifies RPC queueing and owner CPU, matching the TPCC regression mechanism reported in matrixorigin#27628. This PR adds a version-gated, bounded BatchUnlock protocol for ordinary direct remote tables: - group tables by physical owner and send at most 64 tables per RPC; - perform one owner-side closure admission, generation lock, and async drain per batch; - validate every table generation and resolve the complete release plan before the first irreversible unlock; - retain table-scoped Unlock for a single table, proxy handoff mutations, old owners, unknown capabilities, and any rejected/failed batch; - keep origin ledgers attached until batch acknowledgement, so a lost response safely falls back to idempotent table-scoped cleanup; - advertise support only through a successful Lock response under MORPC v30, preserving rolling-upgrade behavior. The result is stronger than merely restoring the pre-matrixorigin#26706 behavior: a transaction touching eight tables on one owner now sends one physical cleanup RPC instead of one effective release plus seven no-op RPCs. ## Correctness and failure-path validation - invalid sizes, duplicate tables, and mixed owners are rejected before closure admission; - a stale later bind rejects the whole batch before the valid prefix is released or the transaction is sealed; - a repeated batch after a lost response is an idempotent success; - a batch rejection leaves all origin ledgers intact and exercises the existing per-table fallback; - proxy/mutation semantics remain table-scoped; - the capability map is bounded by touched tables and cleared with the transaction; - service close remains the terminal cancellation owner, matching ordinary remote Unlock. ## Validation - focused BatchUnlock and adjacent remote/proxy/unknown-commit regressions: pass - full pkg/lockservice suite: pass (97.0s) - full pkg/lockservice race suite: pass (100.8s) - BatchUnlock race stress, count=20: pass - compile checks for pkg/lockservice, pkg/pb/lock, and pkg/defines: pass - coverage: origin/main 87.5%, this PR 87.5%; no coverage decrease - new key-function coverage: 80.6%-100% Eight-table remote-unlock A/B on the same binary and workload (100 iterations, 5 samples): | protocol | median ns/op | allocs/op | | --- | ---: | ---: | | legacy v29 table-scoped | 243,629 | 352 | | v30 bounded batch | 54,218 | 95 | That is about 4.5x faster with about 73% fewer allocations for the regression shape. The end-to-end test also asserts one real MORPC BatchUnlock and zero table-scoped Unlock calls. ## TPCH reproduction note On the requested 10.222.1.55 NVMe environment, stabilized 10 GB TPCH runs did not reproduce the reported +109% regression: the suspected commit averaged 23.784s versus 23.125s at the last-good commit (+2.85%), and q18 was effectively unchanged. A much larger slowdown immediately after data load was transient state/timing contamination rather than commit-specific. Therefore this PR claims and verifies the lockservice/TPCC root-cause fix; it should also help TPCH executions that hit the same concurrent multi-table remote-commit path, but it does not over-attribute the unreproduced +109% TPCH observation to this change.
## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27628 ## What this PR does / why we need it: The table-scoped remote-unlock correctness work after matrixorigin#26706 made every table on the same physical lock owner repeat the full transaction-closure lifecycle: one RPC, closure admission, active-generation lock, async-operation drain, bind validation, unlock, and ledger update. Under concurrent multi-table transactions this amplifies RPC queueing and owner CPU, matching the TPCC regression mechanism reported in matrixorigin#27628. This PR adds a version-gated, bounded BatchUnlock protocol for ordinary direct remote tables: - group tables by physical owner and send at most 64 tables per RPC; - perform one owner-side closure admission, generation lock, and async drain per batch; - validate every table generation and resolve the complete release plan before the first irreversible unlock; - retain table-scoped Unlock for a single table, proxy handoff mutations, old owners, unknown capabilities, and any rejected/failed batch; - keep origin ledgers attached until batch acknowledgement, so a lost response safely falls back to idempotent table-scoped cleanup; - advertise support only through a successful Lock response under MORPC v30, preserving rolling-upgrade behavior. The result is stronger than merely restoring the pre-matrixorigin#26706 behavior: a transaction touching eight tables on one owner now sends one physical cleanup RPC instead of one effective release plus seven no-op RPCs. ## Correctness and failure-path validation - invalid sizes, duplicate tables, and mixed owners are rejected before closure admission; - a stale later bind rejects the whole batch before the valid prefix is released or the transaction is sealed; - a repeated batch after a lost response is an idempotent success; - a batch rejection leaves all origin ledgers intact and exercises the existing per-table fallback; - proxy/mutation semantics remain table-scoped; - the capability map is bounded by touched tables and cleared with the transaction; - service close remains the terminal cancellation owner, matching ordinary remote Unlock. ## Validation - focused BatchUnlock and adjacent remote/proxy/unknown-commit regressions: pass - full pkg/lockservice suite: pass (97.0s) - full pkg/lockservice race suite: pass (100.8s) - BatchUnlock race stress, count=20: pass - compile checks for pkg/lockservice, pkg/pb/lock, and pkg/defines: pass - coverage: origin/main 87.5%, this PR 87.5%; no coverage decrease - new key-function coverage: 80.6%-100% Eight-table remote-unlock A/B on the same binary and workload (100 iterations, 5 samples): | protocol | median ns/op | allocs/op | | --- | ---: | ---: | | legacy v29 table-scoped | 243,629 | 352 | | v30 bounded batch | 54,218 | 95 | That is about 4.5x faster with about 73% fewer allocations for the regression shape. The end-to-end test also asserts one real MORPC BatchUnlock and zero table-scoped Unlock calls. ## TPCH reproduction note On the requested 10.222.1.55 NVMe environment, stabilized 10 GB TPCH runs did not reproduce the reported +109% regression: the suspected commit averaged 23.784s versus 23.125s at the last-good commit (+2.85%), and q18 was effectively unchanged. A much larger slowdown immediately after data load was transient state/timing contamination rather than commit-specific. Therefore this PR claims and verifies the lockservice/TPCC root-cause fix; it should also help TPCH executions that hit the same concurrent multi-table remote-commit path, but it does not over-attribute the unreproduced +109% TPCH observation to this change.
## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27628 ## What this PR does / why we need it: The table-scoped remote-unlock correctness work after matrixorigin#26706 made every table on the same physical lock owner repeat the full transaction-closure lifecycle: one RPC, closure admission, active-generation lock, async-operation drain, bind validation, unlock, and ledger update. Under concurrent multi-table transactions this amplifies RPC queueing and owner CPU, matching the TPCC regression mechanism reported in matrixorigin#27628. This PR adds a version-gated, bounded BatchUnlock protocol for ordinary direct remote tables: - group tables by physical owner and send at most 64 tables per RPC; - perform one owner-side closure admission, generation lock, and async drain per batch; - validate every table generation and resolve the complete release plan before the first irreversible unlock; - retain table-scoped Unlock for a single table, proxy handoff mutations, old owners, unknown capabilities, and any rejected/failed batch; - keep origin ledgers attached until batch acknowledgement, so a lost response safely falls back to idempotent table-scoped cleanup; - advertise support only through a successful Lock response under MORPC v30, preserving rolling-upgrade behavior. The result is stronger than merely restoring the pre-matrixorigin#26706 behavior: a transaction touching eight tables on one owner now sends one physical cleanup RPC instead of one effective release plus seven no-op RPCs. ## Correctness and failure-path validation - invalid sizes, duplicate tables, and mixed owners are rejected before closure admission; - a stale later bind rejects the whole batch before the valid prefix is released or the transaction is sealed; - a repeated batch after a lost response is an idempotent success; - a batch rejection leaves all origin ledgers intact and exercises the existing per-table fallback; - proxy/mutation semantics remain table-scoped; - the capability map is bounded by touched tables and cleared with the transaction; - service close remains the terminal cancellation owner, matching ordinary remote Unlock. ## Validation - focused BatchUnlock and adjacent remote/proxy/unknown-commit regressions: pass - full pkg/lockservice suite: pass (97.0s) - full pkg/lockservice race suite: pass (100.8s) - BatchUnlock race stress, count=20: pass - compile checks for pkg/lockservice, pkg/pb/lock, and pkg/defines: pass - coverage: origin/main 87.5%, this PR 87.5%; no coverage decrease - new key-function coverage: 80.6%-100% Eight-table remote-unlock A/B on the same binary and workload (100 iterations, 5 samples): | protocol | median ns/op | allocs/op | | --- | ---: | ---: | | legacy v29 table-scoped | 243,629 | 352 | | v30 bounded batch | 54,218 | 95 | That is about 4.5x faster with about 73% fewer allocations for the regression shape. The end-to-end test also asserts one real MORPC BatchUnlock and zero table-scoped Unlock calls. ## TPCH reproduction note On the requested 10.222.1.55 NVMe environment, stabilized 10 GB TPCH runs did not reproduce the reported +109% regression: the suspected commit averaged 23.784s versus 23.125s at the last-good commit (+2.85%), and q18 was effectively unchanged. A much larger slowdown immediately after data load was transient state/timing contamination rather than commit-specific. Therefore this PR claims and verifies the lockservice/TPCC root-cause fix; it should also help TPCH executions that hit the same concurrent multi-table remote-commit path, but it does not over-attribute the unreproduced +109% TPCH observation to this change.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27628
What this PR does / why we need it:
The table-scoped remote-unlock correctness work after #26706 made every table on the same physical lock owner repeat the full transaction-closure lifecycle: one RPC, closure admission, active-generation lock, async-operation drain, bind validation, unlock, and ledger update. Under concurrent multi-table transactions this amplifies RPC queueing and owner CPU, matching the TPCC regression mechanism reported in #27628.
This PR adds a version-gated, bounded BatchUnlock protocol for ordinary direct remote tables:
The result is stronger than merely restoring the pre-#26706 behavior: a transaction touching eight tables on one owner now sends one physical cleanup RPC instead of one effective release plus seven no-op RPCs.
Correctness and failure-path validation
Validation
Eight-table remote-unlock A/B on the same binary and workload (100 iterations, 5 samples):
That is about 4.5x faster with about 73% fewer allocations for the regression shape. The end-to-end test also asserts one real MORPC BatchUnlock and zero table-scoped Unlock calls.
TPCH reproduction note
On the requested 10.222.1.55 NVMe environment, stabilized 10 GB TPCH runs did not reproduce the reported +109% regression: the suspected commit averaged 23.784s versus 23.125s at the last-good commit (+2.85%), and q18 was effectively unchanged. A much larger slowdown immediately after data load was transient state/timing contamination rather than commit-specific. Therefore this PR claims and verifies the lockservice/TPCC root-cause fix; it should also help TPCH executions that hit the same concurrent multi-table remote-commit path, but it does not over-attribute the unreproduced +109% TPCH observation to this change.