Skip to content

Commit

Permalink
lightning: skip check if PD returns zero StoreInfo (#49861)
Browse files Browse the repository at this point in the history
close #49743
  • Loading branch information
lance6716 authored Dec 28, 2023
1 parent b56a09b commit 37b61fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions br/pkg/lightning/backend/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 37b61fb

Please sign in to comment.