diff --git a/go/vt/vtctl/grpcvtctldserver/server.go b/go/vt/vtctl/grpcvtctldserver/server.go index b06886e6770..aaf13fb864a 100644 --- a/go/vt/vtctl/grpcvtctldserver/server.go +++ b/go/vt/vtctl/grpcvtctldserver/server.go @@ -2461,6 +2461,15 @@ func (s *VtctldServer) GetUnresolvedTransactions(ctx context.Context, req *vtctl if err != nil { return err } + // The metadata manager is itself not part of the list of participants. + // We should it to the list before showing it to the users. + for _, trnx := range shardTrnxs { + trnx.Participants = append(trnx.Participants, &querypb.Target{ + Keyspace: req.Keyspace, + Shard: shard, + TabletType: topodatapb.TabletType_PRIMARY, + }) + } mu.Lock() defer mu.Unlock() transactions = append(transactions, shardTrnxs...) diff --git a/go/vt/vtctl/grpcvtctldserver/server_test.go b/go/vt/vtctl/grpcvtctldserver/server_test.go index 83dc36b0e9b..896bc65e06b 100644 --- a/go/vt/vtctl/grpcvtctldserver/server_test.go +++ b/go/vt/vtctl/grpcvtctldserver/server_test.go @@ -5370,6 +5370,16 @@ func TestExecuteHook(t *testing.T) { func TestGetUnresolvedTransactions(t *testing.T) { ks := "testkeyspace" + shard1Target := &querypb.Target{ + Keyspace: ks, + Shard: "-80", + TabletType: topodatapb.TabletType_PRIMARY, + } + shard2Target := &querypb.Target{ + Keyspace: ks, + Shard: "80-", + TabletType: topodatapb.TabletType_PRIMARY, + } tests := []struct { name string @@ -5382,24 +5392,25 @@ func TestGetUnresolvedTransactions(t *testing.T) { name: "unresolved transaction on both shards", tmc: &testutil.TabletManagerClient{ GetUnresolvedTransactionsResults: map[string][]*querypb.TransactionMetadata{ - "-80": {{Dtid: "aa"}}, - "80-": {{Dtid: "bb"}}, + "-80": {{Dtid: "aa", Participants: []*querypb.Target{shard2Target}}}, + "80-": {{Dtid: "bb", Participants: []*querypb.Target{shard1Target}}}, }, }, keyspace: "testkeyspace", expected: []*querypb.TransactionMetadata{ - {Dtid: "aa"}, {Dtid: "bb"}, + {Dtid: "aa", Participants: []*querypb.Target{shard2Target, shard1Target}}, + {Dtid: "bb", Participants: []*querypb.Target{shard1Target, shard2Target}}, }, }, { - name: "unresolved transaction on one sharda", + name: "unresolved transaction on one shard", tmc: &testutil.TabletManagerClient{ GetUnresolvedTransactionsResults: map[string][]*querypb.TransactionMetadata{ - "80-": {{Dtid: "bb"}}, + "80-": {{Dtid: "bb", Participants: []*querypb.Target{shard1Target}}}, }, }, keyspace: "testkeyspace", expected: []*querypb.TransactionMetadata{ - {Dtid: "bb"}, + {Dtid: "bb", Participants: []*querypb.Target{shard1Target, shard2Target}}, }, }, {