From 782f77a7c414eab24f94503b0c6ed9b0ea6042c1 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Fri, 24 Mar 2023 17:05:00 -0400 Subject: [PATCH] close resultset earlier in scheduler --- internal/cmd/scheduler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 4fb5dec..de66a75 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -474,7 +474,6 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli logger.Error("failed to fetch accounts", zap.Error(err)) return } - defer rows.Close() var ids []string for rows.Next() { @@ -482,6 +481,8 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli _ = rows.Scan(&id) ids = append(ids, id) } + // Use this instead of deferring as we're going to take a while to get out of this method. + rows.Close() chunks := [][]string{} chunkSize := int(math.Ceil(float64(len(ids)) / float64(accountEnqueueSeconds)))