-
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
Export commitTS of KVTxn #1489
Export commitTS of KVTxn #1489
Conversation
Welcome @b6g! |
337f334
to
fdb6200
Compare
fdb6200
to
be41b52
Compare
be41b52
to
da62319
Compare
ping |
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.
Export CommitTS
LGTM.
I also take a look at pingcap/tidb#57305 which guarantee txn.commit_ts > txn.start_ts
and txn.commit_ts > prev_txn.commit_ts
in session.
To ensure the start_ts
is greater than any exist commit_ts
cross sessions, we may have a field last_commit_ts
in store level and set it to the latest commit_ts. Each time, we fetch start_ts like this:
last_commit_ts = store.last_commit_ts.Load()
start_ts = oracle.GetTSO()
if start_ts < last_commit_ts {
panic(...)
}
This may be another task, @cfzjywxk what's your idea.
@@ -1700,6 +1700,10 @@ func (txn *KVTxn) StartTS() uint64 { | |||
return txn.startTS | |||
} | |||
|
|||
func (txn *KVTxn) CommitTS() uint64 { |
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.
There are still some tests using txn.GetCommitTS
in 1pc_test.go
.
cd integration_tests && go test ./...
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.
@you06 Seems to be an enhancement to add a check before and after the ts allocation
, how about filing an issue for it?
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 integration_tests are fixed.
Sounds a good idea to check store's last_commit_ts is smaller than start_ts, because store's last_commit_ts is not directly allocated from pd.
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 filing an issue for it?
@cfzjywxk It's mentioned in pingcap/tidb#57165 IMO.
In theory, all read requests occurring after the write transaction should use a
read_ts
greater than the previous known transaction'scommit_ts
.
f47074d
to
22f2749
Compare
Signed-off-by: Bin Zhang <[email protected]>
Signed-off-by: Bin Zhang <[email protected]>
22f2749
to
e689dcf
Compare
@@ -1704,6 +1704,10 @@ func (txn *KVTxn) StartTS() uint64 { | |||
return txn.startTS | |||
} | |||
|
|||
func (txn *KVTxn) CommitTS() uint64 { |
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.
func (txn *KVTxn) CommitTS() uint64 { | |
// CommitTS returns the commit timestamp of the already committed transaction, zero if it's not committed yet. | |
func (txn *KVTxn) CommitTS() uint64 { |
Exported functions need explicity comments from the ci & lint.
Signed-off-by: Bin Zhang <[email protected]>
a97868a
to
0e396b2
Compare
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
The Integration Test failed because of timeout. Is it expected? How to trigger it to re-run? |
@you06 Can I get another approval to merge the PR? Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, you06 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 |
@b6g
checking the last commit timestamp after fetching a new ts. |
Ref: pingcap/tidb#57165
Close: #1488
Export KVTxn.CommitTS to make it available in TiDB.