Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetUnresolvedTransactions command for Vtctld #16961

Merged
Merged
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
9 changes: 9 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
23 changes: 17 additions & 6 deletions go/vt/vtctl/grpcvtctldserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}},
},
},
{
Expand Down
Loading