store/tikv: remove use of ReplicaRead transaction option in store/tikv (#24409)

This commit is contained in:
disksing
2021-05-12 20:01:40 +08:00
committed by GitHub
parent e7db533810
commit 9527fa38db
3 changed files with 11 additions and 8 deletions

View File

@ -73,6 +73,8 @@ func (s *tikvSnapshot) SetOption(opt int, val interface{}) {
s.KVSnapshot.SetNotFillCache(val.(bool))
case tikvstore.SnapshotTS:
s.KVSnapshot.SetSnapshotTS(val.(uint64))
case tikvstore.ReplicaRead:
s.KVSnapshot.SetReplicaRead(val.(tikvstore.ReplicaReadType))
case tikvstore.TaskID:
s.KVSnapshot.SetTaskID(val.(uint64))
default:

View File

@ -144,6 +144,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.SetPessimistic(val.(bool))
case tikvstore.SnapshotTS:
txn.KVTxn.GetSnapshot().SetSnapshotTS(val.(uint64))
case tikvstore.ReplicaRead:
txn.KVTxn.GetSnapshot().SetReplicaRead(val.(tikvstore.ReplicaReadType))
case tikvstore.TaskID:
txn.KVTxn.GetSnapshot().SetTaskID(val.(uint64))
case tikvstore.InfoSchema:

View File

@ -565,10 +565,6 @@ func (s *KVSnapshot) IterReverse(k []byte) (unionstore.Iterator, error) {
// value of this option. Only ReplicaRead is supported for snapshot
func (s *KVSnapshot) SetOption(opt int, val interface{}) {
switch opt {
case kv.ReplicaRead:
s.mu.Lock()
s.mu.replicaRead = val.(kv.ReplicaReadType)
s.mu.Unlock()
case kv.CollectRuntimeStats:
s.mu.Lock()
s.mu.stats = val.(*SnapshotRuntimeStats)
@ -589,10 +585,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
// DelOption deletes an option.
func (s *KVSnapshot) DelOption(opt int) {
switch opt {
case kv.ReplicaRead:
s.mu.Lock()
s.mu.replicaRead = kv.ReplicaReadLeader
s.mu.Unlock()
case kv.CollectRuntimeStats:
s.mu.Lock()
s.mu.stats = nil
@ -611,6 +603,13 @@ func (s *KVSnapshot) SetKeyOnly(b bool) {
s.keyOnly = b
}
// SetReplicaRead sets up the replica read type.
func (s *KVSnapshot) SetReplicaRead(readType kv.ReplicaReadType) {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.replicaRead = readType
}
// SetIsolationLevel sets the isolation level used to scan data from tikv.
func (s *KVSnapshot) SetIsolationLevel(level IsoLevel) {
s.isolationLevel = level