-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
variable: session variable tidb_enable_commit_ts_order_check #57313
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The already exists
tidb_last_txn_info
could be used to track the last transaction information in current session.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.
It stores the json encoded
TxnInfo
. We have to json decode to use the last commit_ts, which seems hacky.#57305 implements the check.
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.
Does this make sense?
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.
Since this check condition should always hold, it can always be verified without introducing a dedicated parameter. Introducing system variables or configuration items typically increases the using complexity for users.
From an implementation perspective, introducing a separate interface to expose the
commit_ts
of the previous transaction is also costly. Thelast_txn_info
cannot be directly used as it requires deserialization.Another possible way is to modify the
txn commit hook function
interface, allowing the KV client to set thecommit_ts
into a specific field within the session variable's statement context during the commit process likesessVars.stmtContext.commitTS = commitTS
.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 try
txn commit hook function
. Thanks!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.
@cfzjywxk Is this what you suggested 571c73e#diff-3749ef84f018df1c4d5541271a230702b5c8200c8f44268ffdff63886842f268R521?
I feel
commitTS
should be stored in theSessionVars.LastCommitTS
instead ofStmtCtx
, becauseStmtCtx
is for the current txn, whileLastCommitTS
is from the last txn.I can refactor CommitHook to take
*TxnInfo
in a separate PR, which involvesclient-go
.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.
It seems that using the commit hook approach would still require modifying the
client-go
interface if we want to avoid deserializingtxn info
.Perhaps the original approach in [PR #1489 of client-go] is better, by adding a
commit_ts
interface to the transaction inclient-go
for TiDB to use. It would avoid the performance impact caused by deserializingtxn info
.If there are future scenarios requiring access to the last transaction info, we could consider extending the newly exported
commit_ts
interface into alast_txn_info
interface. This would allow it to return structured info instead of a string.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.
sgtm
As you pointed out, this session variable is not necessary, as we should always check commit_s. I will close this PR.