mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 21:27:42 +00:00
tweak scheduler to only run one enqueue at a time
This commit is contained in:
parent
04d59f280d
commit
71f04afb8a
1 changed files with 2 additions and 1 deletions
|
@ -67,7 +67,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
|
|||
}
|
||||
|
||||
s := gocron.NewScheduler(time.UTC)
|
||||
s.Every(1).Second().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
|
||||
s.Every(1).Second().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
|
||||
s.Every(1).Second().Do(func() { cleanQueues(ctx, logger, queue) })
|
||||
s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db, redis) })
|
||||
s.Every(1).Minute().Do(func() { cleanAccounts(ctx, logger, db) })
|
||||
|
@ -209,6 +209,7 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, statsd *statsd.
|
|||
OR last_checked_at < $2
|
||||
ORDER BY last_checked_at
|
||||
LIMIT 2000
|
||||
FOR UPDATE SKIP LOCKED
|
||||
)
|
||||
UPDATE accounts
|
||||
SET last_enqueued_at = $3
|
||||
|
|
Loading…
Reference in a new issue