Skip to content

Commit

Permalink
store/mockstore/mocktikv: Add mvccGetByKeyNoLock() to avoid double RL…
Browse files Browse the repository at this point in the history
…ock (#16924)
  • Loading branch information
Anonymous authored Mar 31, 2021
1 parent c660cee commit 51a5a3d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion store/mockstore/mocktikv/mvcc_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ func (mvcc *MVCCLevelDB) MvccGetByStartTS(starTS uint64) (*kvrpcpb.MvccInfo, []b
iter.Next()
}

return mvcc.MvccGetByKey(key), key
return mvcc.mvccGetByKeyNoLock(key), key
}

var valueTypeOpMap = [...]kvrpcpb.Op{
Expand All @@ -1684,6 +1684,11 @@ func (mvcc *MVCCLevelDB) MvccGetByKey(key []byte) *kvrpcpb.MvccInfo {
mvcc.mu.RLock()
defer mvcc.mu.RUnlock()

return mvcc.mvccGetByKeyNoLock(key)
}

// mvcc.mu.RLock must be held before calling mvccGetByKeyNoLock.
func (mvcc *MVCCLevelDB) mvccGetByKeyNoLock(key []byte) *kvrpcpb.MvccInfo {
info := &kvrpcpb.MvccInfo{}

startKey := mvccEncode(key, lockVer)
Expand Down

0 comments on commit 51a5a3d

Please sign in to comment.