Orphan transactions never reached the ledger, so their locks are safe to clean immediately, just like Deleted transactions (when tokens spent). The recovery system already marks these transactions as Orphan, but the cleanup doesn't check for it.
That means:
DELETE FROM token_locks WHERE
-- Dead transactions (immediate cleanup)
consumer_tx_id IN (
SELECT tx_id FROM requests
WHERE status IN (Deleted, Orphan)
)
Orphan transactions never reached the ledger, so their locks are safe to clean immediately, just like Deleted transactions (when tokens spent). The recovery system already marks these transactions as Orphan, but the cleanup doesn't check for it.
That means:
DELETE FROM token_locks WHERE
-- Dead transactions (immediate cleanup)
consumer_tx_id IN (
SELECT tx_id FROM requests
WHERE status IN (Deleted, Orphan)
)