Skip to content

Commit

Permalink
store/tikv: remove CompareTS (#24657)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing committed May 17, 2021
1 parent e92df20 commit 557c94b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
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

0 comments on commit 557c94b

Please sign in to comment.