-
Notifications
You must be signed in to change notification settings - Fork 6k
txn: also update the @@tidb_last_txn_info
for readyonly or rollback txns
#61057
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
Conversation
/hold |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #61057 +/- ##
================================================
+ Coverage 73.1387% 73.5264% +0.3876%
================================================
Files 1724 1724
Lines 477000 480744 +3744
================================================
+ Hits 348872 353474 +4602
+ Misses 106705 105846 -859
- Partials 21423 21424 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
@@ -919,6 +919,7 @@ func (s *session) CommitTxn(ctx context.Context) error { | |||
r, ctx := tracing.StartRegionEx(ctx, "session.CommitTxn") | |||
defer r.End() | |||
|
|||
s.setLastTxnInfoBeforeTxnEnd() |
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.
How about putting it in onTxnEnd
?
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.
Seems onTxnEnd,the txn info has been cleared
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.
After this line, in doCommitWithRetry
-> doCommit
, it seems it still have possibility to finally enter a rolled-back state or encounter error. Perhaps it's better to consider put it in a later place where the commit/rollback result is finally determined.
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.
Seems if a txn comitted or fails to commit, the CommitHook will update it:
tidb/pkg/sessiontxn/isolation/base.go
Line 506 in c71ebaf
txn.SetOption(kv.CommitHook, func(info string, _ error) { sessVars.LastTxnInfo = info }) |
setLastTxnInfoBeforeTxnEnd
in CommitTxn
will be overridden at this time. So setLastTxnInfoBeforeTxnEnd
is only affects some readonly txns.
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.
Better to add comments to explain why it is put here.
/retest |
@@ -919,6 +919,7 @@ func (s *session) CommitTxn(ctx context.Context) error { | |||
r, ctx := tracing.StartRegionEx(ctx, "session.CommitTxn") | |||
defer r.End() | |||
|
|||
s.setLastTxnInfoBeforeTxnEnd() |
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.
After this line, in doCommitWithRetry
-> doCommit
, it seems it still have possibility to finally enter a rolled-back state or encounter error. Perhaps it's better to consider put it in a later place where the commit/rollback result is finally determined.
/retest |
/unhold |
Co-authored-by: cfzjywxk <[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.
LGTM
@@ -919,6 +919,7 @@ func (s *session) CommitTxn(ctx context.Context) error { | |||
r, ctx := tracing.StartRegionEx(ctx, "session.CommitTxn") | |||
defer r.End() | |||
|
|||
s.setLastTxnInfoBeforeTxnEnd() |
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.
Better to add comments to explain why it is put here.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, zyguan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #61056
What changed and how does it work?
also update the
@@tidb_last_txn_info
for readyonly or rollback transactionsCheck List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.