The wrap_db_retry decorator must be used outside the outermost DB
transaction. Using it on a subtransaction means that the main
transaction gets marked for rollback but not closed, leaving the session
in the 'inactive' state.
This change ensures that the decorator is not used when we update the
previous resource from within a subtransaction as part of creating a
replacement resource, and instead the retry happens outside the main