Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/lockservice/orphan_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,20 @@ func TestValidTxnWithInvalidRemoteTxn(t *testing.T) {
require.False(t, hold.isValidRemoteTxn(pb.WaitTxn{TxnID: []byte{1}, CreatedOn: "s0"}))
}

func TestValidTxnWithInactiveRemoteTxnAndNotifyFoundCommitting(t *testing.T) {
hold := newMapBasedTxnHandler(
"s1",
getLogger(""),
newFixedSlicePool(16),
func(sid string) (bool, error) { return false, nil },
func(ot []pb.OrphanTxn) ([][]byte, error) { return [][]byte{{1}}, nil },
func(txn pb.WaitTxn) (bool, error) {
return false, nil
},
).(*mapBasedTxnHolder)
require.True(t, hold.isValidRemoteTxn(pb.WaitTxn{TxnID: []byte{1}, CreatedOn: "s0"}))
}

func TestValidTxnWithInvalidRemoteTxnAndNotifyOK(t *testing.T) {
hold := newMapBasedTxnHandler(
"s1",
Expand Down
8 changes: 7 additions & 1 deletion pkg/lockservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,13 @@ func (h *mapBasedTxnHolder) isValidRemoteTxn(txn pb.WaitTxn) bool {

valid, err := h.validTxn(txn)
if err == nil {
return valid
if valid {
return true
}
// A remote CN active-txn miss does not prove the txn is safe to unlock.
// The commit response may be lost after TN has already committed it, so
// require the allocator to confirm the txn cannot still be committing.
return !h.canUnlockRemoteTxn(txn)
}
logValidTxnFailed(h.logger, txn, err)
if isRetryError(err) {
Expand Down
Loading