Skip to content

Commit

Permalink
store/tikv: remove use of IsStatenessReadOnly 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 89c0e6c commit 6228e22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions store/driver/txn/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (s *tikvSnapshot) SetOption(opt int, val interface{}) {
s.KVSnapshot.SetReplicaRead(val.(tikvstore.ReplicaReadType))
case tikvstore.TaskID:
s.KVSnapshot.SetTaskID(val.(uint64))
case tikvstore.IsStalenessReadOnly:
s.KVSnapshot.SetIsStatenessReadOnly(val.(bool))
default:
s.KVSnapshot.SetOption(opt, val)
}
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 @@ -161,6 +161,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.SetEnable1PC(val.(bool))
case tikvstore.TxnScope:
txn.SetScope(val.(string))
case tikvstore.IsStalenessReadOnly:
txn.KVTxn.GetSnapshot().SetIsStatenessReadOnly(val.(bool))
default:
txn.KVTxn.SetOption(opt, val)
}
Expand Down
11 changes: 7 additions & 4 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
s.mu.Unlock()
case kv.SampleStep:
s.sampleStep = val.(uint32)
case kv.IsStalenessReadOnly:
s.mu.Lock()
s.mu.isStaleness = val.(bool)
s.mu.Unlock()
case kv.MatchStoreLabels:
s.mu.Lock()
s.mu.matchStoreLabels = val.([]*metapb.StoreLabel)
Expand Down Expand Up @@ -628,6 +624,13 @@ func (s *KVSnapshot) SetTaskID(id uint64) {
s.mu.taskID = id
}

// SetIsStatenessReadOnly indicates whether the transaction is staleness read only transaction
func (s *KVSnapshot) SetIsStatenessReadOnly(b bool) {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.isStaleness = b
}

// SnapCacheHitCount gets the snapshot cache hit count. Only for test.
func (s *KVSnapshot) SnapCacheHitCount() int {
return int(atomic.LoadInt64(&s.mu.hitCnt))
Expand Down

0 comments on commit 6228e22

Please sign in to comment.