David Ewins
Error library

Reversal runs twice when two requests race

SupabaseLikely fix

Postgres RPC

There is no error message for this one, only the symptom in the title.

Cause

The idempotency guard read "already reversed?" and then inserted. Two callers could both pass the check before either wrote.

Fix

Move check and insert into one database function that holds the same per-user advisory lock as the spend path (pg_advisory_xact_lock). A unique index only works if there is exactly one valid row per key.

More Supabase errors

Search all errors