-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add conclude transaction command to vtctld service #16693
Add conclude transaction command to vtctld service #16693
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16693 +/- ##
==========================================
- Coverage 68.93% 68.93% -0.01%
==========================================
Files 1565 1566 +1
Lines 201741 201855 +114
==========================================
+ Hits 139076 139152 +76
- Misses 62665 62703 +38 ☔ View full report in Codecov by Sentry. |
048e39c
to
ca4c140
Compare
84c5238
to
73f1a84
Compare
Instead of the two current commands Like The advantage of this approach is that we minimize the new commands required for additional functionality like (just brainstorming here) Not sure if it is an overkill here and we will not have any more operations for DTs, but thought I would mention it. |
This is a reasonable ask, at the moment we know of 2 commands but it can grow over time. I will make the required changes. |
…ager Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
b79484d
to
5facda3
Compare
// ConcludeTransaction makes a ConcludeTransaction gRPC call to a vtctld. | ||
ConcludeTransaction = &cobra.Command{ | ||
Use: "conclude <dtid> [<keyspace/shard> ...]", | ||
Short: "Concludes the unresolved transaction by rolling back the prepared transaction on all participating shards and removing the transaction metadata record.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short: "Concludes the unresolved transaction by rolling back the prepared transaction on all participating shards and removing the transaction metadata record.", | |
Short: "Concludes the unresolved transaction by rolling back prepared transactions on all participating shards and removing the transaction metadata record.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
every shard will have at most 1 prepared transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is how we see this distributed transaction.
one transaction that spans multiple shards
or multiple independent transactions on the shards.
For user, it is one transaction.
Internally it is multiple transactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to use singular, you can use each
Concludes the unresolved transaction by rolling back the prepared transaction on each participating shard and removing the transaction metadata record
OR
Concludes the unresolved transaction by rolling back prepared transactions on all participating shards and removing the transaction metadata record
are both grammatically correct. Using the singular with "all" is not. Ask ChatGPT and you will see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take the first one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deepthi could you also approve the PR if everything else looks good?
@@ -28,6 +28,7 @@ Available Commands: | |||
DeleteShards Deletes the specified shards from the topology. | |||
DeleteSrvVSchema Deletes the SrvVSchema object in the given cell. | |||
DeleteTablets Deletes tablet(s) from the topology. | |||
DistributedTransaction Perform commands on distributed transaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be plural? I see from the discussion below that there is just one dt per shard: is that for all users and connections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plural makes more sense to me too, especially for DistributedTransactions list
since there can be multiple transactions that are listed.
Use: "conclude <dtid> [<keyspace/shard> ...]", | ||
Short: "Concludes the unresolved transaction by rolling back the prepared transaction on all participating shards and removing the transaction metadata record.", | ||
Aliases: []string{"Conclude"}, | ||
Args: cobra.MinimumNArgs(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the examples it is not entirely clear to me what the arguments to conclude will look like. But we have found it more useful to specify the parameters as flags rather than depend on args
because it is easy to forget the order or delimiters etc. We had that problem a lot with the earlier vreplication commands. It is a bit more typing
For example it could be
DistributedTransactions Conclude --keyspace ks1 --shards -40,a0- --dtid 82345
OR with shorthand codes
DistributedTransactions Conclude -k ks1 -s -40,a0- --dtid 82345
You can decide if this works better or not ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A transaction can span multiple keyspaces so keyspace and shard will go in pair like keyspace/shard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not find a good way to record the participants list.
We keep it like this for now.
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
…nsactions Signed-off-by: Harshit Gangal <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
|
||
// ConcludeTransaction makes a ConcludeTransaction gRPC call to a vtctld. | ||
ConcludeTransaction = &cobra.Command{ | ||
Use: "conclude <dtid> [<keyspace/shard> ...]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we even take in <keyspace/shard> list? Why don't we just conclude the transaction everywhere. Like the user only has one option, which is to conclude the transaction on all the shards, not on some shards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking about it that if the list of keyspace/shard is not provided we will get it and then conclude on all.
This is more from if the user gets the unresolved transactions list then it knows which all shards are involved and can provide the list to conclude.
We can make the flow better. Let's do that in a follow up PR.
for _, rm := range req.Participants { | ||
eg.Go(func() error { | ||
primary, err := s.getPrimaryTablet(newCtx, rm) | ||
if err != nil { | ||
return err | ||
} | ||
return s.tmc.ConcludeTransaction(newCtx, primary.Tablet, req.Dtid, false) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the ss.Target
tablet is part of the requested participants. Would we not end up calling ConcludeTransaction on it twice? First with the last argument being false, and the next time with true.
Also, if the ss.Target
is not part of the requested participants, should we even do the second ConcludeTransaction
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the Metadata Manager Shard, it's conclude is about deleting the Transaction record once everything is resolved in other participating shards.
Participating shards is exclusive of Metadata Manager shard.
Description
This PR adds support for vtctld server and vtctld client to Conclude open distributed transactions.
It also changes the command usage for Distributed Transactions
Command Usage
List:
DistributedTransaction list <keyspace>
Conclude:
DistributedTransaction conclude <dtid> [<keyspace/shard> ...]
Related Issue(s)
Checklist