diff --git a/go/vt/vttablet/tabletserver/dt_executor.go b/go/vt/vttablet/tabletserver/dt_executor.go index 52e9366f322..0721f9ab613 100644 --- a/go/vt/vttablet/tabletserver/dt_executor.go +++ b/go/vt/vttablet/tabletserver/dt_executor.go @@ -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)) } diff --git a/go/vt/vttablet/tabletserver/dt_executor_test.go b/go/vt/vttablet/tabletserver/dt_executor_test.go index f6369cfb978..8311ece7cee 100644 --- a/go/vt/vttablet/tabletserver/dt_executor_test.go +++ b/go/vt/vttablet/tabletserver/dt_executor_test.go @@ -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"