Skip to content

Commit

Permalink
restore: add retry...
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Juncen <yujuncen@pingcap.com>
  • Loading branch information
YuJuncen committed Dec 22, 2021
1 parent c2c22f0 commit 582a9fd
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions br/pkg/restore/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,23 @@ func (rs *RegionSplitter) ScatterRegions(ctx context.Context, newRegions []*Regi
rs.waitForSplit(ctx, region.Region.Id)
}

// No retry needed, the internal implementation of `ScatterRegions` involves retry already.
err := rs.client.ScatterRegions(ctx, newRegions)
if isUnsupportedError(err) {
log.Warn("batch scatter isn't supported, rollback to old method", logutil.ShortError(err))
rs.ScatterRegionsWithBackoffer(
ctx, newRegions,
// backoff about 6s, or we give up scattering this region.
&exponentialBackoffer{
attempt: 7,
baseBackoff: 100 * time.Millisecond,
})
return
}
err := utils.WithRetry(ctx, func() error {
err := rs.client.ScatterRegions(ctx, newRegions)
if isUnsupportedError(err) {
log.Warn("batch scatter isn't supported, rollback to old method", logutil.ShortError(err))
rs.ScatterRegionsWithBackoffer(
ctx, newRegions,
// backoff about 6s, or we give up scattering this region.
&exponentialBackoffer{
attempt: 7,
baseBackoff: 100 * time.Millisecond,
})
return nil
}
return err
// the retry is for the temporary network errors during sending request.
}, &exponentialBackoffer{attempt: 3, baseBackoff: 500 * time.Millisecond})

if err != nil {
log.Warn("failed to batch scatter region", logutil.ShortError(err))
}
Expand Down

0 comments on commit 582a9fd

Please sign in to comment.