Skip to content

Commit

Permalink
store/tikv: fix misuse of PD client's GetStore
Browse files Browse the repository at this point in the history
Signed-off-by: longfangsong <longfangsong@icloud.com>
  • Loading branch information
longfangsong committed Mar 30, 2021
1 parent 67874c5 commit 5d6f8ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1778,16 +1778,20 @@ func (s *Store) reResolve(c *RegionCache) (bool, error) {
} else {
metrics.RegionCacheCounterWithGetStoreOK.Inc()
}
if err != nil {
// when the error is "[pd] store field in rpc response not set",
// it means load Store from PD success but pd didn't found the store
// so this error should be handled by next `if` instead of here
if err != nil && err.Error() != "[pd] store field in rpc response not set" {
logutil.BgLogger().Error("loadStore from PD failed", zap.Uint64("id", s.storeID), zap.Error(err))
// we cannot do backoff in reResolve loop but try check other store and wait tick.
return false, err
}
if store == nil || store.State == metapb.StoreState_Tombstone {
if store == nil {
// store has be removed in PD, we should invalidate all regions using those store.
logutil.BgLogger().Info("invalidate regions in removed store",
zap.Uint64("store", s.storeID), zap.String("add", s.addr))
atomic.AddUint32(&s.epoch, 1)
atomic.StoreUint64(&s.state, uint64(deleted))
metrics.RegionCacheCounterWithInvalidateStoreRegionsOK.Inc()
return false, nil
}
Expand Down

0 comments on commit 5d6f8ca

Please sign in to comment.