handle empty candidate set for scheduling

This commit is contained in:
Andre Medeiros 2023-03-16 10:06:51 -04:00
parent 73e7927d3f
commit f9fd53610f
1 changed files with 9 additions and 1 deletions

View File

@ -504,6 +504,15 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
logger.Error("failed to check for locked accounts", zap.Error(err))
}
if len(enqueued) == 0 {
logger.Info("no viable candidates to enqueue",
zap.Int("offset", offset),
zap.Int("attempts", len(ids)),
zap.Int("enqueued", len(enqueued)),
)
return
}
if err = queue.Publish(enqueued...); err != nil {
logger.Error("failed to enqueue account batch",
zap.Error(err),
@ -519,7 +528,6 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
zap.Int("attempts", len(ids)),
zap.Int("enqueued", len(enqueued)),
)
}(ctx, i)
}
wg.Wait()