-
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
Conversation
Hi @b6g. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @b6g. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dveeden 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 |
[LGTM Timeline notifier]Timeline:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #57313 +/- ##
================================================
+ Coverage 72.8577% 73.4246% +0.5668%
================================================
Files 1672 1672
Lines 462711 462756 +45
================================================
+ Hits 337121 339777 +2656
+ Misses 104809 102274 -2535
+ Partials 20781 20705 -76
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -1915,6 +1915,10 @@ var defaultSysVars = []*SysVar{ | |||
s.allowTiFlashCop = TiDBOptOn(val) | |||
return nil | |||
}}, | |||
{Scope: ScopeSession, Name: TiDBEnableCommitTSOrderCheck, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { | |||
s.EnableCommitTSOrderCheck = TiDBOptOn(val) |
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. The last_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 the commit_ts
into a specific field within the session variable's statement context during the commit process like sessVars.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 the SessionVars.LastCommitTS
instead of StmtCtx
, because StmtCtx
is for the current txn, while LastCommitTS
is from the last txn.
I can refactor CommitHook to take *TxnInfo
in a separate PR, which involves client-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 deserializing txn info
.
Perhaps the original approach in [PR #1489 of client-go] is better, by adding a commit_ts
interface to the transaction in client-go
for TiDB to use. It would avoid the performance impact caused by deserializing txn info
.
If there are future scenarios requiring access to the last transaction info, we could consider extending the newly exported commit_ts
interface into a last_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.
What problem does this PR solve?
Issue Number: ref #57165
Problem Summary:
Add a session variable
tidb_enable_commit_ts_order_check
to enable checkingcommit_ts
in #57305.What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.