Skip to content

Commit

Permalink
Lightning: increase backoff if split fails (#49518) (#50164)
Browse files Browse the repository at this point in the history
close #49517
  • Loading branch information
ti-chi-bot authored Jan 25, 2024
1 parent 97a9bf8 commit 6f6386a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,9 @@ func (local *local) ImportEngine(ctx context.Context, engineUUID uuid.UUID, regi
failpoint.Inject("failToSplit", func(_ failpoint.Value) {
needSplit = true
})

backOffTime := 10 * time.Second
maxbackoffTime := 120 * time.Second
for i := 0; i < maxRetryTimes; i++ {
err = local.SplitAndScatterRegionInBatches(ctx, unfinishedRanges, needSplit, maxBatchSplitRanges)
if err == nil || common.IsContextCanceledError(err) {
Expand All @@ -1700,6 +1703,16 @@ func (local *local) ImportEngine(ctx context.Context, engineUUID uuid.UUID, regi

log.FromContext(ctx).Warn("split and scatter failed in retry", zap.Stringer("uuid", engineUUID),
log.ShortError(err), zap.Int("retry", i))

select {
case <-time.After(backOffTime):
case <-ctx.Done():
return ctx.Err()
}
backOffTime *= 2
if backOffTime > maxbackoffTime {
backOffTime = maxbackoffTime
}
}
if err != nil {
log.FromContext(ctx).Error("split & scatter ranges failed", zap.Stringer("uuid", engineUUID), log.ShortError(err))
Expand Down

0 comments on commit 6f6386a

Please sign in to comment.