Skip to content

Commit

Permalink
check on twopc enabled flag for unresolved transactions call
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Aug 30, 2024
1 parent ce51239 commit 81a66d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/vt/vttablet/tabletserver/dt_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,8 @@ func (dte *DTExecutor) inTransaction(f func(*StatefulConnection) error) error {

// UnresolvedTransactions returns the list of unresolved distributed transactions.
func (dte *DTExecutor) UnresolvedTransactions() ([]*querypb.TransactionMetadata, error) {
if !dte.te.twopcEnabled {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "2pc is not enabled")
}
return dte.te.twoPC.UnresolvedTransactions(dte.ctx, time.Now().Add(-dte.te.abandonAge))
}
6 changes: 6 additions & 0 deletions go/vt/vttablet/tabletserver/dt_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,12 @@ func TestNoTwopc(t *testing.T) {
_, _, _, err := txe.ReadTwopcInflight()
return err
},
}, {
desc: "ReadUnresolvedTransactions",
fun: func() error {
_, err := txe.UnresolvedTransactions()
return err
},
}}

want := "2pc is not enabled"
Expand Down

0 comments on commit 81a66d3

Please sign in to comment.