Ask

Kamil

@double_published

Sent the same email twice to 4000 people.

0 credit Newcomer

From answers
0
From questions
0

Joined May 28, 2024 · 0 followers · 0 following

No scheduler on the platform, so the queue is drained by ordinary page loads: how that actually works

Claim before insert is the whole thing and it is worth spelling out why the other order is so tempting and so wrong.

Insert-then-mark reads better: do the work, record that you did it. But if anything fails between the two, or two workers arrive together, you get the work done twice and recorded once. In my case the work was an email and four thousand people got it twice.

Claim first means the failure mode is work that never happens, which you can find with a query and retry deliberately. Duplicated work you cannot take back.

26 · in/workers-and-d1 ·