diff --git a/store/tikv/mockstore/mocktikv/mvcc_leveldb.go b/store/tikv/mockstore/mocktikv/mvcc_leveldb.go index f8085fb3f1..ab9b7dc598 100644 --- a/store/tikv/mockstore/mocktikv/mvcc_leveldb.go +++ b/store/tikv/mockstore/mocktikv/mvcc_leveldb.go @@ -27,14 +27,21 @@ import ( "github.com/pingcap/goleveldb/leveldb/util" "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/parser/terror" - "github.com/pingcap/tidb/kv" + "github.com/pingcap/tidb/store/tikv/logutil" "github.com/pingcap/tidb/store/tikv/mockstore/deadlock" "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/store/tikv/util/codec" - "github.com/pingcap/tidb/util/logutil" "go.uber.org/zap" ) +// Used for pessimistic lock wait time +// these two constants are special for lock protocol with tikv +// 0 means always wait, -1 means nowait, others meaning lock wait in milliseconds +var ( + LockAlwaysWait = int64(0) + LockNoWait = int64(-1) +) + // MVCCLevelDB implements the MVCCStore interface. type MVCCLevelDB struct { // Key layout: @@ -502,14 +509,14 @@ func (mvcc *MVCCLevelDB) PessimisticLock(req *kvrpcpb.PessimisticLockRequest) *k if err != nil { anyError = true } - if lockWaitTime == kv.LockNoWait { + if lockWaitTime == LockNoWait { if _, ok := err.(*ErrLocked); ok { break } } } if anyError { - if lockWaitTime != kv.LockNoWait { + if lockWaitTime != LockNoWait { // TODO: remove this when implement sever side wait. simulateServerSideWaitLock(errs) } diff --git a/store/tikv/mockstore/mocktikv/session.go b/store/tikv/mockstore/mocktikv/session.go index 9e9d352b7b..7997c6c9f4 100644 --- a/store/tikv/mockstore/mocktikv/session.go +++ b/store/tikv/mockstore/mocktikv/session.go @@ -18,7 +18,6 @@ import ( "github.com/pingcap/kvproto/pkg/errorpb" "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/pingcap/tidb/ddl/placement" ) // Session stores session scope rpc data. @@ -164,7 +163,7 @@ func (s *Session) checkKeyInRegion(key []byte) bool { func isTiFlashStore(store *metapb.Store) bool { for _, l := range store.GetLabels() { - if l.GetKey() == placement.EngineLabelKey && l.GetValue() == placement.EngineLabelTiFlash { + if l.GetKey() == "engine" && l.GetValue() == "tiflash" { return true } }