Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store/tikv: remove use of MatchStoreLabels transaction option in store/tikv #24465

Merged
merged 10 commits into from
May 12, 2021
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"
"github.com/pingcap/tidb/store/tikv"
tikvstore "github.com/pingcap/tidb/store/tikv/kv"
Expand Down Expand Up @@ -73,6 +74,8 @@ func (s *tikvSnapshot) SetOption(opt int, val interface{}) {
s.KVSnapshot.SetNotFillCache(val.(bool))
case tikvstore.SnapshotTS:
s.KVSnapshot.SetSnapshotTS(val.(uint64))
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 @@ -152,6 +153,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.SetEnable1PC(val.(bool))
case tikvstore.TxnScope:
txn.SetScope(val.(string))
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 @@ -583,10 +583,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
s.mu.Lock()
s.mu.isStaleness = val.(bool)
s.mu.Unlock()
case kv.MatchStoreLabels:
s.mu.Lock()
s.mu.matchStoreLabels = val.([]*metapb.StoreLabel)
s.mu.Unlock()
}
}

Expand Down Expand Up @@ -625,6 +621,13 @@ func (s *KVSnapshot) SetPriority(pri Priority) {
s.priority = pri
}

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