Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

Commit c4695ef

Browse files
xaviershaylparry
authored andcommitted
Prevent jobs from being enqueued in the past.
It's relatively easy for this to happen by accident (e.g. time drift on a rogue server), and it throws a spanner in the works if you're monitoring for oldest job in the queue.
1 parent 038cb16 commit c4695ef

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/que/job.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Job
1717
(
1818
coalesce($1, 'default')::text,
1919
coalesce($2, 100)::smallint,
20-
coalesce($3, now())::timestamptz,
20+
greatest($3, now())::timestamptz,
2121
$4::text,
2222
coalesce($5, '[]')::jsonb,
2323
coalesce($6, '{}')::jsonb,
@@ -34,7 +34,7 @@ class Job
3434
SELECT
3535
coalesce(queue, 'default')::text,
3636
coalesce(priority, 100)::smallint,
37-
coalesce(run_at, now())::timestamptz,
37+
greatest(run_at, now())::timestamptz,
3838
job_class::text,
3939
coalesce(args, '[]')::jsonb,
4040
coalesce(kwargs, '{}')::jsonb,

0 commit comments

Comments
 (0)