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

store/tikv: remove CompareTS #24657

Merged
merged 2 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion executor/stale_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (s *testStaleTxnSerialSuite) TestTimeBoundedStalenessTxn(c *C) {
if testcase.useSafeTS {
c.Assert(tk.Se.GetSessionVars().TxnCtx.StartTS, Equals, testcase.injectSafeTS)
} else {
c.Assert(oracle.CompareTS(tk.Se.GetSessionVars().TxnCtx.StartTS, testcase.injectSafeTS), Equals, 1)
c.Assert(tk.Se.GetSessionVars().TxnCtx.StartTS, Greater, testcase.injectSafeTS)
}
tk.MustExec("commit")
failpoint.Disable("github.com/pingcap/tidb/store/tikv/injectSafeTS")
Expand Down
19 changes: 0 additions & 19 deletions store/tikv/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,6 @@ func GoTimeToTS(t time.Time) uint64 {
return uint64(ts)
}

// CompareTS is used to compare two timestamps.
// If tsoOne > tsoTwo, returns 1.
// If tsoOne = tsoTwo, returns 0.
// If tsoOne < tsoTwo, returns -1.
func CompareTS(tsoOne, tsoTwo uint64) int {
tsOnePhy := ExtractPhysical(tsoOne)
tsOneLog := ExtractLogical(tsoOne)
tsTwoPhy := ExtractPhysical(tsoTwo)
tsTwoLog := ExtractLogical(tsoTwo)

if tsOnePhy > tsTwoPhy || (tsOnePhy == tsTwoPhy && tsOneLog > tsTwoLog) {
return 1
}
if tsOnePhy == tsTwoPhy && tsOneLog == tsTwoLog {
return 0
}
return -1
}

// GoTimeToLowerLimitStartTS returns the min start_ts of the uncommitted transaction.
// maxTxnTimeUse means the max time a Txn May use (in ms) from its begin to commit.
func GoTimeToLowerLimitStartTS(now time.Time, maxTxnTimeUse int64) uint64 {
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func extractStartTs(store *KVStore, options kv.TransactionOption) (uint64, error
startTs = *options.MinStartTS
// If the safeTS is larger than the minStartTS, we will use safeTS as StartTS, otherwise we will use
// minStartTS directly.
if oracle.CompareTS(startTs, safeTS) < 0 {
if startTs < safeTS {
startTs = safeTS
}
} else if options.MaxPrevSec != nil {
Expand Down