diff --git a/store/tikv/region_cache.go b/store/tikv/region_cache.go index 445f8286905c7..00d51837b4526 100644 --- a/store/tikv/region_cache.go +++ b/store/tikv/region_cache.go @@ -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 }