diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go index 005a98e985..177a44571f 100644 --- a/internal/locate/region_cache.go +++ b/internal/locate/region_cache.go @@ -2164,10 +2164,11 @@ func (c *RegionCache) PDClient() pd.Client { return c.pdClient } -// GetTiFlashStores returns the information of all tiflash nodes. +// GetTiFlashStores returns the information of all tiflash nodes. Like `GetAllStores`, the method only returns resolved +// stores so that users won't be bothered by tombstones. (related issue: https://github.com/pingcap/tidb/issues/46602) func (c *RegionCache) GetTiFlashStores(labelFilter LabelFilter) []*Store { return c.filterStores(nil, func(s *Store) bool { - return s.storeType == tikvrpc.TiFlash && labelFilter(s.labels) + return s.storeType == tikvrpc.TiFlash && labelFilter(s.labels) && s.getResolveState() == resolved }) } diff --git a/internal/locate/store_cache.go b/internal/locate/store_cache.go index 235cbd0a1d..5defacbe40 100644 --- a/internal/locate/store_cache.go +++ b/internal/locate/store_cache.go @@ -411,7 +411,7 @@ func (s *Store) reResolve(c storeCache) (bool, error) { if store == nil || store.GetState() == metapb.StoreState_Tombstone { // 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)) + zap.Uint64("store", s.storeID), zap.String("addr", s.addr)) atomic.AddUint32(&s.epoch, 1) s.setResolveState(tombstone) metrics.RegionCacheCounterWithInvalidateStoreRegionsOK.Inc()