mirror of https://github.com/tikv/client-go.git
region_cache: filter out unresolved stores when GetTiFlashStores (#1262)
* region_cache: filter out unresolved stores when GetTiFlashStores Signed-off-by: zyguan <zhongyangguan@gmail.com> * address comment Signed-off-by: zyguan <zhongyangguan@gmail.com> --------- Signed-off-by: zyguan <zhongyangguan@gmail.com>
This commit is contained in:
parent
5a4905d2f5
commit
abc9bb2878
|
|
@ -2191,10 +2191,11 @@ func (c *RegionCache) PDClient() pd.Client {
|
||||||
return c.pdClient
|
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 {
|
func (c *RegionCache) GetTiFlashStores(labelFilter LabelFilter) []*Store {
|
||||||
return c.filterStores(nil, func(s *Store) bool {
|
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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ func (s *Store) reResolve(c storeCache) (bool, error) {
|
||||||
if store == nil || store.GetState() == metapb.StoreState_Tombstone {
|
if store == nil || store.GetState() == metapb.StoreState_Tombstone {
|
||||||
// store has be removed in PD, we should invalidate all regions using those store.
|
// store has be removed in PD, we should invalidate all regions using those store.
|
||||||
logutil.BgLogger().Info("invalidate regions in removed 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)
|
atomic.AddUint32(&s.epoch, 1)
|
||||||
s.setResolveState(tombstone)
|
s.setResolveState(tombstone)
|
||||||
metrics.RegionCacheCounterWithInvalidateStoreRegionsOK.Inc()
|
metrics.RegionCacheCounterWithInvalidateStoreRegionsOK.Inc()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue