Review funkt
This commit is contained in:
25
node_modules/bullmq/dist/esm/postgres/commands/extend_locks.sql
generated
vendored
Normal file
25
node_modules/bullmq/dist/esm/postgres/commands/extend_locks.sql
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Refresh multiple active-job locks in one round-trip; returns the ids whose
|
||||
-- locks could not be renewed. Params: $1 queue, $2 ids (text[]), $3 tokens
|
||||
-- (text[]), $4 lock_ms, $5 now_ms.
|
||||
WITH input AS (
|
||||
SELECT ids.job_id, toks.token, ids.ord
|
||||
FROM unnest($2::text[]) WITH ORDINALITY AS ids(job_id, ord)
|
||||
JOIN unnest($3::text[]) WITH ORDINALITY AS toks(token, ord)
|
||||
USING (ord)
|
||||
),
|
||||
updated AS (
|
||||
UPDATE job
|
||||
SET locked_until_ms = $5::bigint + $4::bigint
|
||||
FROM input
|
||||
WHERE queue = $1
|
||||
AND id = input.job_id
|
||||
AND state = 'active'
|
||||
AND lock_token = input.token
|
||||
RETURNING id
|
||||
)
|
||||
SELECT input.job_id AS id
|
||||
FROM input
|
||||
LEFT JOIN updated
|
||||
ON updated.id = input.job_id
|
||||
WHERE updated.id IS NULL
|
||||
ORDER BY input.ord;
|
||||
Reference in New Issue
Block a user