Skip to content

Commit

Permalink
address the comment
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <[email protected]>
  • Loading branch information
Yisaer committed May 14, 2021
1 parent 0923391 commit fbe67c3
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions store/tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,10 @@ var oracleUpdateInterval = 2000

// KVStore contains methods to interact with a TiKV cluster.
type KVStore struct {
clusterID uint64
uuid string
oracle oracle.Oracle
clientMu struct {
sync.RWMutex
client Client
}
clusterID uint64
uuid string
oracle oracle.Oracle
client atomic.Value
pdClient pd.Client
regionCache *RegionCache
lockResolver *LockResolver
Expand Down Expand Up @@ -144,7 +141,7 @@ func NewKVStore(uuid string, pdClient pd.Client, spkv SafePointKV, client Client
closed: make(chan struct{}),
replicaReadSeed: rand.Uint32(),
}
store.clientMu.client = reqCollapse{client}
store.client.Store(reqCollapse{client})
store.lockResolver = newLockResolver(store)

go store.runSafePointChecker()
Expand Down Expand Up @@ -346,16 +343,12 @@ func (s *KVStore) SetOracle(oracle oracle.Oracle) {

// SetTiKVClient resets the client instance.
func (s *KVStore) SetTiKVClient(client Client) {
s.clientMu.Lock()
defer s.clientMu.Unlock()
s.clientMu.client = client
s.client.Store(client)
}

// GetTiKVClient gets the client instance.
func (s *KVStore) GetTiKVClient() (client Client) {
s.clientMu.RLock()
defer s.clientMu.RUnlock()
return s.clientMu.client
return s.client.Load().(Client)
}

func (s *KVStore) getSafeTS(storeID uint64) uint64 {
Expand Down

0 comments on commit fbe67c3

Please sign in to comment.