Warn when filtering out regions without leaders (#1773)

Signed-off-by: ekexium <eke@fastmail.com>
This commit is contained in:
ekexium 2025-10-21 13:08:00 +08:00 committed by GitHub
parent 0172e26932
commit 6da8a064e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -2425,6 +2425,10 @@ func (c *RegionCache) handleRegionInfos(bo *retry.Backoffer, regionsInfo []*rout
for _, r := range regionsInfo { for _, r := range regionsInfo {
// Leader id = 0 indicates no leader. // Leader id = 0 indicates no leader.
if needLeader && (r.Leader == nil || r.Leader.GetId() == 0) { if needLeader && (r.Leader == nil || r.Leader.GetId() == 0) {
logutil.BgLogger().Warn("filter out region without leader",
zap.Uint64("regionId", r.Meta.Id),
zap.String("startKey", redact.Key(r.Meta.StartKey)),
zap.String("endKey", redact.Key(r.Meta.EndKey)))
continue continue
} }
region, err := newRegion(bo, c, r) region, err := newRegion(bo, c, r)
@ -2437,7 +2441,7 @@ func (c *RegionCache) handleRegionInfos(bo *retry.Backoffer, regionsInfo []*rout
return nil, nil return nil, nil
} }
if len(regions) < len(regionsInfo) { if len(regions) < len(regionsInfo) {
logutil.Logger(context.Background()).Debug( logutil.Logger(context.Background()).Warn(
"regionCache: scanRegion finished but some regions has no leader.") "regionCache: scanRegion finished but some regions has no leader.")
} }
return regions, nil return regions, nil