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

txnkv/transaction/prewrite: tiny refactor HandleSingleBatch #1529

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AndreMouche
Copy link
Member

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

Copy link

ti-chi-bot bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from andremouche, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 18, 2024
Signed-off-by: AndreMouche <[email protected]>
handler.attempts++
if handler.action.hasRpcRetries {
handler.req.IsRetryRequest = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

Suggested change
}
}
if handler.attempts == 1 {
return
}

zap.Stringer("region", &handler.batch.region),
zap.Int("attempts", handler.attempts),
)
handler.begin = time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handler.begin = time.Now()
handler.begin = reqBegin

handler.sender.SetRPCError(nil)

// Update CommitDetails
reqDuration := time.Since(handler.begin)
Copy link
Contributor

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)
Copy link
Contributor

@you06 you06 Dec 27, 2024

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:

Suggested change
handler.committer.run(handler.committer, nil, false)
handler.committer.ttlManager.run(handler.committer, nil, false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants