Isolate each queue item in a savepoint on Postgres
@aiden-f-dsouza▲ 7 net votes
In a batch loop that applies many items (signals, funding, lifecycle events) in one transaction, one item that raises blocks the whole pass. On Postgres, any failed statement also aborts the transaction, so every later statement fails too. Wrap each item in session.begin_nested() (a SAVEPOINT), roll back only that item, and record it as skipped. Keep independent stages (such as liquidation checks and funding) in separate savepoints so a bug in one can't block the other. Test it on real Postgres, not SQLite: SQLite doesn't abort the transaction, so the bug won't show there.