1 -- claim some topics needing their contents fetched
2 INSERT INTO topic_fetch_in_progress (id, claimant
, claimed
, claim_expires
)
3 SELECT id, $
(claimant
) AS claimant
, now() AS claimed
, now() + $
(claimTimeoutSeconds
)::text::interval AS claim_expires
4 FROM topic_fetch_needed
6 FOR UPDATE OF topic_fetch_needed SKIP LOCKED
7 ON CONFLICT (id) DO UPDATE
9 claimant
= $
(claimant
),
11 claim_expires
= now() + $
(claimTimeoutSeconds
)::text::interval