Repository navigation
workaround txn commit failed but tn handled - #22139
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
|
This pull request has been removed from the queue for the following reason: The merge conditions cannot be satisfied due to failing checks:You may have to fix your CI before adding the pull request to the queue again. |
workaround txn commit failed but tn handled Approved by: @zhangxu19830126
## 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 #25704 Related: #25553, #22115, #22139 ## What this PR does / why we need it: An `ErrTxnUnknown` means TN may already have accepted the Commit while CN lost the response. Releasing its pessimistic locks with an empty or synthetic timestamp can therefore allow a conflicting writer to proceed before TN has resolved the original Commit. This PR makes unknown-result cleanup fail closed without changing the normal Commit or Rollback path: - The multi-request sender classifies an ambiguous Commit `Stream.Send` completion failure as `ErrTxnUnknown`; known pre-send failures and Rollback retain their existing behavior. - The txn operator transfers only pessimistic `ErrTxnUnknown` lock cleanup to lockservice. Optimistic unknown results retain their workspace/status handling but do not retain lock-resolution admission because they own no pessimistic locks. - The resolver keeps the source txn registered, retries bounded remote cleanup, and unlocks only after `CannotCommit` returns a non-empty allocator fence timestamp. - Resolver-owned user transactions continue consuming their existing `MaxActiveTxn` slots until terminal lock cleanup. Allocator outages therefore backpressure new user transactions through the existing cancellable queue. - Internal pessimistic Commits reserve a separate finite safety slot before workspace preparation and before Commit can be sent to TN. The limit is `max(MaxActiveTxn, 1024)` in production. At saturation, a new internal Commit returns the existing CN-busy error and performs full Rollback/Unlock before any Commit request is sent. Known outcomes release immediately; unknown outcomes transfer the slot to the resolver until terminal cleanup. This bounds internal resolver pending entries, active holders, retained locks, and retry work without putting normal user transactions on the internal quota. - Every new Commit carries an absolute deadline and a source-lockservice-local monotonic sequence. TN applies its configured HLC max-offset before treating this CN-derived deadline as expired. Unknown-result fences preserve each `(sequence, expiry)` pair while the frontier is below 1024 entries. At saturation, they collapse to one conservative per-source fence using the maximum sequence and latest expiry. - Proxy holder handoff is published locally only after owner acknowledgement. A response-lost handoff records its replacement as pending, and retries preserve that representative even if later local shared holders join. - The owner holder map migrates its key together with the replacement value, so the replacement is recognized as holder for subsequent Unlock. This is not a transaction 2PC change. Normal user Commit, known terminal errors, Rollback, and optimistic lock cleanup do not enter the resolver or add lockservice RPCs. ## Validation: - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/client -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/rpc ./pkg/frontend/test/mock_lock -count=1` - `GOFLAGS='-mod=mod' go test -race ./pkg/txn/client -run 'Test(OptimisticCommitUnknownReleasesAdmission|CommitUnknownScheduleFailureReleasesAdmission|InternalCommitUnknownAdmissionIsBounded|CommitUnknownRetainsAdmissionUntilResolution|CommitUnknownResolvedBeforeCloseReleasesAdmissionOnce)$' -count=20` - `GOFLAGS='-mod=mod' go test -race ./pkg/lockservice -run 'TestResolveCommitUnknownWaitsForAllocatorFence$' -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -run 'TestResolveCommitUnknown(WaitsForAllocatorFence|CompletesWhenTxnAlreadyUnlocked)$' -count=1` - `git diff --check` `go test ./pkg/txn/service -run '^TestCommitRequestExpired$' -count=1` is blocked locally before package compilation because this host lacks the repository CGo dependencies (`usearch.h`, `roaring.h`, and `xxhash.h`). --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#25722) ## 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#25704 Related: matrixorigin#25553, matrixorigin#22115, matrixorigin#22139 ## What this PR does / why we need it: An `ErrTxnUnknown` means TN may already have accepted the Commit while CN lost the response. Releasing its pessimistic locks with an empty or synthetic timestamp can therefore allow a conflicting writer to proceed before TN has resolved the original Commit. This PR makes unknown-result cleanup fail closed without changing the normal Commit or Rollback path: - The multi-request sender classifies an ambiguous Commit `Stream.Send` completion failure as `ErrTxnUnknown`; known pre-send failures and Rollback retain their existing behavior. - The txn operator transfers only pessimistic `ErrTxnUnknown` lock cleanup to lockservice. Optimistic unknown results retain their workspace/status handling but do not retain lock-resolution admission because they own no pessimistic locks. - The resolver keeps the source txn registered, retries bounded remote cleanup, and unlocks only after `CannotCommit` returns a non-empty allocator fence timestamp. - Resolver-owned user transactions continue consuming their existing `MaxActiveTxn` slots until terminal lock cleanup. Allocator outages therefore backpressure new user transactions through the existing cancellable queue. - Internal pessimistic Commits reserve a separate finite safety slot before workspace preparation and before Commit can be sent to TN. The limit is `max(MaxActiveTxn, 1024)` in production. At saturation, a new internal Commit returns the existing CN-busy error and performs full Rollback/Unlock before any Commit request is sent. Known outcomes release immediately; unknown outcomes transfer the slot to the resolver until terminal cleanup. This bounds internal resolver pending entries, active holders, retained locks, and retry work without putting normal user transactions on the internal quota. - Every new Commit carries an absolute deadline and a source-lockservice-local monotonic sequence. TN applies its configured HLC max-offset before treating this CN-derived deadline as expired. Unknown-result fences preserve each `(sequence, expiry)` pair while the frontier is below 1024 entries. At saturation, they collapse to one conservative per-source fence using the maximum sequence and latest expiry. - Proxy holder handoff is published locally only after owner acknowledgement. A response-lost handoff records its replacement as pending, and retries preserve that representative even if later local shared holders join. - The owner holder map migrates its key together with the replacement value, so the replacement is recognized as holder for subsequent Unlock. This is not a transaction 2PC change. Normal user Commit, known terminal errors, Rollback, and optimistic lock cleanup do not enter the resolver or add lockservice RPCs. ## Validation: - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/client -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/rpc ./pkg/frontend/test/mock_lock -count=1` - `GOFLAGS='-mod=mod' go test -race ./pkg/txn/client -run 'Test(OptimisticCommitUnknownReleasesAdmission|CommitUnknownScheduleFailureReleasesAdmission|InternalCommitUnknownAdmissionIsBounded|CommitUnknownRetainsAdmissionUntilResolution|CommitUnknownResolvedBeforeCloseReleasesAdmissionOnce)$' -count=20` - `GOFLAGS='-mod=mod' go test -race ./pkg/lockservice -run 'TestResolveCommitUnknownWaitsForAllocatorFence$' -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -run 'TestResolveCommitUnknown(WaitsForAllocatorFence|CompletesWhenTxnAlreadyUnlocked)$' -count=1` - `git diff --check` `go test ./pkg/txn/service -run '^TestCommitRequestExpired$' -count=1` is blocked locally before package compilation because this host lacks the repository CGo dependencies (`usearch.h`, `roaring.h`, and `xxhash.h`). --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#25722) ## 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#25704 Related: matrixorigin#25553, matrixorigin#22115, matrixorigin#22139 ## What this PR does / why we need it: An `ErrTxnUnknown` means TN may already have accepted the Commit while CN lost the response. Releasing its pessimistic locks with an empty or synthetic timestamp can therefore allow a conflicting writer to proceed before TN has resolved the original Commit. This PR makes unknown-result cleanup fail closed without changing the normal Commit or Rollback path: - The multi-request sender classifies an ambiguous Commit `Stream.Send` completion failure as `ErrTxnUnknown`; known pre-send failures and Rollback retain their existing behavior. - The txn operator transfers only pessimistic `ErrTxnUnknown` lock cleanup to lockservice. Optimistic unknown results retain their workspace/status handling but do not retain lock-resolution admission because they own no pessimistic locks. - The resolver keeps the source txn registered, retries bounded remote cleanup, and unlocks only after `CannotCommit` returns a non-empty allocator fence timestamp. - Resolver-owned user transactions continue consuming their existing `MaxActiveTxn` slots until terminal lock cleanup. Allocator outages therefore backpressure new user transactions through the existing cancellable queue. - Internal pessimistic Commits reserve a separate finite safety slot before workspace preparation and before Commit can be sent to TN. The limit is `max(MaxActiveTxn, 1024)` in production. At saturation, a new internal Commit returns the existing CN-busy error and performs full Rollback/Unlock before any Commit request is sent. Known outcomes release immediately; unknown outcomes transfer the slot to the resolver until terminal cleanup. This bounds internal resolver pending entries, active holders, retained locks, and retry work without putting normal user transactions on the internal quota. - Every new Commit carries an absolute deadline and a source-lockservice-local monotonic sequence. TN applies its configured HLC max-offset before treating this CN-derived deadline as expired. Unknown-result fences preserve each `(sequence, expiry)` pair while the frontier is below 1024 entries. At saturation, they collapse to one conservative per-source fence using the maximum sequence and latest expiry. - Proxy holder handoff is published locally only after owner acknowledgement. A response-lost handoff records its replacement as pending, and retries preserve that representative even if later local shared holders join. - The owner holder map migrates its key together with the replacement value, so the replacement is recognized as holder for subsequent Unlock. This is not a transaction 2PC change. Normal user Commit, known terminal errors, Rollback, and optimistic lock cleanup do not enter the resolver or add lockservice RPCs. ## Validation: - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/client -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/rpc ./pkg/frontend/test/mock_lock -count=1` - `GOFLAGS='-mod=mod' go test -race ./pkg/txn/client -run 'Test(OptimisticCommitUnknownReleasesAdmission|CommitUnknownScheduleFailureReleasesAdmission|InternalCommitUnknownAdmissionIsBounded|CommitUnknownRetainsAdmissionUntilResolution|CommitUnknownResolvedBeforeCloseReleasesAdmissionOnce)$' -count=20` - `GOFLAGS='-mod=mod' go test -race ./pkg/lockservice -run 'TestResolveCommitUnknownWaitsForAllocatorFence$' -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -run 'TestResolveCommitUnknown(WaitsForAllocatorFence|CompletesWhenTxnAlreadyUnlocked)$' -count=1` - `git diff --check` `go test ./pkg/txn/service -run '^TestCommitRequestExpired$' -count=1` is blocked locally before package compilation because this host lacks the repository CGo dependencies (`usearch.h`, `roaring.h`, and `xxhash.h`). --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#25722) ## 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#25704 Related: matrixorigin#25553, matrixorigin#22115, matrixorigin#22139 ## What this PR does / why we need it: An `ErrTxnUnknown` means TN may already have accepted the Commit while CN lost the response. Releasing its pessimistic locks with an empty or synthetic timestamp can therefore allow a conflicting writer to proceed before TN has resolved the original Commit. This PR makes unknown-result cleanup fail closed without changing the normal Commit or Rollback path: - The multi-request sender classifies an ambiguous Commit `Stream.Send` completion failure as `ErrTxnUnknown`; known pre-send failures and Rollback retain their existing behavior. - The txn operator transfers only pessimistic `ErrTxnUnknown` lock cleanup to lockservice. Optimistic unknown results retain their workspace/status handling but do not retain lock-resolution admission because they own no pessimistic locks. - The resolver keeps the source txn registered, retries bounded remote cleanup, and unlocks only after `CannotCommit` returns a non-empty allocator fence timestamp. - Resolver-owned user transactions continue consuming their existing `MaxActiveTxn` slots until terminal lock cleanup. Allocator outages therefore backpressure new user transactions through the existing cancellable queue. - Internal pessimistic Commits reserve a separate finite safety slot before workspace preparation and before Commit can be sent to TN. The limit is `max(MaxActiveTxn, 1024)` in production. At saturation, a new internal Commit returns the existing CN-busy error and performs full Rollback/Unlock before any Commit request is sent. Known outcomes release immediately; unknown outcomes transfer the slot to the resolver until terminal cleanup. This bounds internal resolver pending entries, active holders, retained locks, and retry work without putting normal user transactions on the internal quota. - Every new Commit carries an absolute deadline and a source-lockservice-local monotonic sequence. TN applies its configured HLC max-offset before treating this CN-derived deadline as expired. Unknown-result fences preserve each `(sequence, expiry)` pair while the frontier is below 1024 entries. At saturation, they collapse to one conservative per-source fence using the maximum sequence and latest expiry. - Proxy holder handoff is published locally only after owner acknowledgement. A response-lost handoff records its replacement as pending, and retries preserve that representative even if later local shared holders join. - The owner holder map migrates its key together with the replacement value, so the replacement is recognized as holder for subsequent Unlock. This is not a transaction 2PC change. Normal user Commit, known terminal errors, Rollback, and optimistic lock cleanup do not enter the resolver or add lockservice RPCs. ## Validation: - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/client -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/txn/rpc ./pkg/frontend/test/mock_lock -count=1` - `GOFLAGS='-mod=mod' go test -race ./pkg/txn/client -run 'Test(OptimisticCommitUnknownReleasesAdmission|CommitUnknownScheduleFailureReleasesAdmission|InternalCommitUnknownAdmissionIsBounded|CommitUnknownRetainsAdmissionUntilResolution|CommitUnknownResolvedBeforeCloseReleasesAdmissionOnce)$' -count=20` - `GOFLAGS='-mod=mod' go test -race ./pkg/lockservice -run 'TestResolveCommitUnknownWaitsForAllocatorFence$' -count=1` - `GOFLAGS='-mod=mod' go test ./pkg/lockservice -run 'TestResolveCommitUnknown(WaitsForAllocatorFence|CompletesWhenTxnAlreadyUnlocked)$' -count=1` - `git diff --check` `go test ./pkg/txn/service -run '^TestCommitRequestExpired$' -count=1` is blocked locally before package compilation because this host lacks the repository CGo dependencies (`usearch.h`, `roaring.h`, and `xxhash.h`). --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
User description
What type of PR is this?
Which issue(s) this PR fixes:
issue #22115
What this PR does / why we need it:
workaround txn commit failed but tn handled
PR Type
Bug fix
Description
Add workaround for transaction commit failures
Set CommitTS to now+10s when commit send fails
Include test coverage for the workaround behavior
Changes diagram
Changes walkthrough 📝
operator.go
Add commit failure workaround logicpkg/txn/client/operator.go
doSendmethod for commit failuresCommitTSto current time plus 10 seconds as workaroundoperator_test.go
Add test for commit workaroundpkg/txn/client/operator_test.go
TestCommitSendErrorSetsCommitTSWorkaround