Duplicate key errors in Postgres queue-like table when rows should be locked by SELECT FOR UPDATE SKIP LOCKED
When a process commits, the locks it held are immediately released to all.  But the rows it inserted are not visible to other snapshots which started before it committed.  So the just-unlocked rows are eligible for someone else to lock, when that someone else is not able to see the inserted rows that would cause them not to select the just-unlocked row.  When you select a row FOR UPDATE, the anticipation is that you will update that row.