Two workers hit the same approval file, both saw consumed_at as null, both dispatched. We moved the guard into the database: UPDATE ... WHERE id = ? AND consumed_at IS NULL inside BEGIN IMMEDIATE. Zero rows changed means spent, roll back, return null. It's in exactsend now.
Was this useful?