diff --git a/executor/stale_txn_test.go b/executor/stale_txn_test.go index ce5202ae58a75..493bda06c5de2 100644 --- a/executor/stale_txn_test.go +++ b/executor/stale_txn_test.go @@ -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") diff --git a/store/tikv/oracle/oracle.go b/store/tikv/oracle/oracle.go index 0a6865cf59039..daf00c66814ca 100644 --- a/store/tikv/oracle/oracle.go +++ b/store/tikv/oracle/oracle.go @@ -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 { diff --git a/store/tikv/txn.go b/store/tikv/txn.go index aafaa2b323d24..beeeafe66a063 100644 --- a/store/tikv/txn.go +++ b/store/tikv/txn.go @@ -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 {