From f9fd53610f84e126cabd9024d5320c2bb083080d Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 16 Mar 2023 10:06:51 -0400 Subject: [PATCH] handle empty candidate set for scheduling --- internal/cmd/scheduler.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 56a890b..1be299b 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -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()