Skip to content

Commit

Permalink
feat: fix couple of issues
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Nov 6, 2024
1 parent 99b81f2 commit e8279bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions go/cmd/vtctldclient/command/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ func commandGetUnresolvedTransactions(cmd *cobra.Command, args []string) error {
AbandonAge: unresolvedTransactionsOptions.AbandonAge,
})
if err != nil {
prettyPrintError(err)
return err
}

data, err := cli.MarshalJSON(resp.Transactions)
if err != nil {
prettyPrintError(err)
return err
}
fmt.Println(string(data))
Expand Down Expand Up @@ -150,13 +152,27 @@ func commandGetTransactionInfo(cmd *cobra.Command, args []string) error {
})

if err != nil || rts == nil {
prettyPrintError(err)
return err
}

fmt.Println(string(rts.String()))
return nil
}

func prettyPrintError(err error) {
if err == nil {
return
}
st := struct {
Error string `json:"error"`
}{
Error: err.Error(),
}
data, _ := cli.MarshalJSON(st)
fmt.Println(string(data))
}

func init() {
GetUnresolvedTransactions.Flags().StringVarP(&unresolvedTransactionsOptions.Keyspace, "keyspace", "k", "", "unresolved transactions list for the given keyspace.")
GetUnresolvedTransactions.Flags().Int64VarP(&unresolvedTransactionsOptions.AbandonAge, "abandon-age", "a", 0, "unresolved transactions list which are older than the specified age(in seconds).")
Expand Down
4 changes: 4 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,10 @@ func (s *VtctldServer) GetTransactionInfo(ctx context.Context, req *vtctldatapb.
Statements: rts.Statements,
})

// The metadata manager is itself not part of the list of participants.
// We should it to the list before showing it to the users.
transaction.Participants = append(transaction.Participants, ss.Target)

return resp, nil
}

Expand Down

0 comments on commit e8279bc

Please sign in to comment.