Skip to content

Commit

Permalink
store/tikv: remove use of ReplicaRead transaction option in store/tikv (
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing committed May 12, 2021
1 parent e7db533 commit 9527fa3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions store/driver/txn/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 7 additions & 8 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9527fa3

Please sign in to comment.