Skip to content

Commit

Permalink
Lightning: increase backoff if split fails (pingcap#49518)
Browse files Browse the repository at this point in the history
  • Loading branch information
mittalrishabh authored and AilinKid committed Jan 17, 2024
1 parent 5f4a49b commit 846fb38
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ func (local *Backend) prepareAndSendJob(
needSplit = true
})
logger := log.FromContext(ctx).With(zap.String("uuid", engine.ID())).Begin(zap.InfoLevel, "split and scatter ranges")
backOffTime := 10 * time.Second
maxbackoffTime := 120 * time.Second
for i := 0; i < maxRetryTimes; i++ {
failpoint.Inject("skipSplitAndScatter", func() {
failpoint.Break()
Expand All @@ -823,6 +825,15 @@ func (local *Backend) prepareAndSendJob(

log.FromContext(ctx).Warn("split and scatter failed in retry", zap.String("engine ID", engine.ID()),
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
}
}
logger.End(zap.ErrorLevel, err)
if err != nil {
Expand Down

0 comments on commit 846fb38

Please sign in to comment.