-
Notifications
You must be signed in to change notification settings - Fork 225
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
txnkv/transaction/prewrite: tiny refactor HandleSingleBatch #1529
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: AndreMouche <[email protected]>
e2980be
to
0df9619
Compare
Signed-off-by: AndreMouche <[email protected]>
Signed-off-by: AndreMouche <[email protected]>
handler.attempts++ | ||
if handler.action.hasRpcRetries { | ||
handler.req.IsRetryRequest = true | ||
} |
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 about
} | |
} | |
if handler.attempts == 1 { | |
return | |
} |
zap.Stringer("region", &handler.batch.region), | ||
zap.Int("attempts", handler.attempts), | ||
) | ||
handler.begin = time.Now() |
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.
handler.begin = time.Now() | |
handler.begin = reqBegin |
handler.sender.SetRPCError(nil) | ||
|
||
// Update CommitDetails | ||
reqDuration := time.Since(handler.begin) |
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.
handler.begin
is not reqBegin
.
// In this case 1PC is not expected to be used, but still check it for safety. | ||
if int64(handler.committer.txnSize) > config.GetGlobalConfig().TiKVClient.TTLRefreshedTxnSize && | ||
prewriteResp.OnePcCommitTs == 0 { | ||
handler.committer.run(handler.committer, nil, 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.
Though ttlManager
is embed in twoPhaseCommitter
, call committer.run
is little weird. Better to change it to:
handler.committer.run(handler.committer, nil, false) | |
handler.committer.ttlManager.run(handler.committer, nil, false) |
Do some tiny refactor for
handleSingleBatch
Extracted some functions to make more friendly to reviewers and maintainers, meanwhile make the unit testing easier to write too