close resultset earlier in scheduler

This commit is contained in:
Andre Medeiros 2023-03-24 17:05:00 -04:00
parent 568ed6f51c
commit 782f77a7c4

View file

@ -474,7 +474,6 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
logger.Error("failed to fetch accounts", zap.Error(err)) logger.Error("failed to fetch accounts", zap.Error(err))
return return
} }
defer rows.Close()
var ids []string var ids []string
for rows.Next() { for rows.Next() {
@ -482,6 +481,8 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
_ = rows.Scan(&id) _ = rows.Scan(&id)
ids = append(ids, 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{} chunks := [][]string{}
chunkSize := int(math.Ceil(float64(len(ids)) / float64(accountEnqueueSeconds))) chunkSize := int(math.Ceil(float64(len(ids)) / float64(accountEnqueueSeconds)))