Skip to content

Commit

Permalink
store/tikv: remove use of MatchStoreLabels transaction option in stor…
Browse files Browse the repository at this point in the history
…e/tikv (#24465)
  • Loading branch information
disksing committed May 12, 2021
1 parent b6b352c commit e584062
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions store/driver/txn/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"unsafe"

"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/tidb/kv"
derr "github.com/pingcap/tidb/store/driver/error"
"github.com/pingcap/tidb/store/tikv"
Expand Down Expand Up @@ -80,6 +81,8 @@ func (s *tikvSnapshot) SetOption(opt int, val interface{}) {
s.KVSnapshot.SetTaskID(val.(uint64))
case tikvstore.IsStalenessReadOnly:
s.KVSnapshot.SetIsStatenessReadOnly(val.(bool))
case tikvstore.MatchStoreLabels:
s.KVSnapshot.SetMatchStoreLabels(val.([]*metapb.StoreLabel))
default:
s.KVSnapshot.SetOption(opt, val)
}
Expand Down
3 changes: 3 additions & 0 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/opentracing/opentracing-go"
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/sessionctx/binloginfo"
Expand Down Expand Up @@ -163,6 +164,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.SetScope(val.(string))
case tikvstore.IsStalenessReadOnly:
txn.KVTxn.GetSnapshot().SetIsStatenessReadOnly(val.(bool))
case tikvstore.MatchStoreLabels:
txn.KVTxn.GetSnapshot().SetMatchStoreLabels(val.([]*metapb.StoreLabel))
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.MatchStoreLabels:
s.mu.Lock()
s.mu.matchStoreLabels = val.([]*metapb.StoreLabel)
s.mu.Unlock()
}
}

Expand Down Expand Up @@ -631,6 +627,13 @@ func (s *KVSnapshot) SetIsStatenessReadOnly(b bool) {
s.mu.isStaleness = b
}

// SetMatchStoreLabels sets up labels to filter target stores.
func (s *KVSnapshot) SetMatchStoreLabels(labels []*metapb.StoreLabel) {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.matchStoreLabels = labels
}

// 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 e584062

Please sign in to comment.