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) }