Skip to content

Commit

Permalink
server: tolerate no leader on report bucket (tikv#7720)
Browse files Browse the repository at this point in the history
close tikv#7719

server: tolerate no leader on handling report buckets.

Signed-off-by: Ping Yu <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
pingyu and ti-chi-bot[bot] committed Jan 17, 2024
1 parent 8f4f81f commit a90e13e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,19 @@ func (s *GrpcServer) ReportBuckets(stream pdpb.PD_ReportBucketsServer) error {
if buckets == nil || len(buckets.Keys) == 0 {
continue
}
var (
storeLabel string
storeAddress string
)
store := rc.GetLeaderStoreByRegionID(buckets.GetRegionId())
if store == nil {
return errors.Errorf("the store of the bucket in region %v is not found ", buckets.GetRegionId())
// As TiKV report buckets just after the region heartbeat, for new created region, PD may receive buckets report before the first region heartbeat is handled.
// So we should not return error here.
log.Warn("the store of the bucket in region is not found ", zap.Uint64("region-id", buckets.GetRegionId()))
} else {
storeLabel = strconv.FormatUint(store.GetID(), 10)
storeAddress = store.GetAddress()
}
storeLabel := strconv.FormatUint(store.GetID(), 10)
storeAddress := store.GetAddress()
bucketReportCounter.WithLabelValues(storeAddress, storeLabel, "report", "recv").Inc()

start := time.Now()
Expand Down

0 comments on commit a90e13e

Please sign in to comment.