From 37b61fbd6acfc434f9b7be118497164565b79173 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Thu, 28 Dec 2023 13:51:28 +0800 Subject: [PATCH] lightning: skip check if PD returns zero StoreInfo (#49861) close pingcap/tidb#49743 --- br/pkg/lightning/backend/local/local.go | 5 +++++ br/pkg/lightning/backend/local/local_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/br/pkg/lightning/backend/local/local.go b/br/pkg/lightning/backend/local/local.go index ae9f3b52ce7d6..a4b0450c7d723 100644 --- a/br/pkg/lightning/backend/local/local.go +++ b/br/pkg/lightning/backend/local/local.go @@ -1428,6 +1428,11 @@ func checkDiskAvail(ctx context.Context, store *pdhttp.StoreInfo) error { zap.String("capacity", store.Status.Capacity), zap.Error(err)) return nil } + if capacity <= 0 { + // PD will return a zero value StoreInfo if heartbeat is not received after + // startup, skip temporarily. + return nil + } available, err := units.RAMInBytes(store.Status.Available) if err != nil { logger.Warn("failed to parse available", diff --git a/br/pkg/lightning/backend/local/local_test.go b/br/pkg/lightning/backend/local/local_test.go index 780d3c621dcd5..f45d6324b82f1 100644 --- a/br/pkg/lightning/backend/local/local_test.go +++ b/br/pkg/lightning/backend/local/local_test.go @@ -2386,4 +2386,9 @@ func TestCheckDiskAvail(t *testing.T) { ctx := context.Background() err := checkDiskAvail(ctx, store) require.NoError(t, err) + + // pd may return this StoreInfo before the store reports heartbeat + store = &http.StoreInfo{Status: http.StoreStatus{LeaderWeight: 1.0, RegionWeight: 1.0}} + err = checkDiskAvail(ctx, store) + require.NoError(t, err) }