Switch from retry_lock_with_transaction to retry_lock with an explicit subject.transaction block in the else path since it performs multiple DB operations.
retry_lock_with_transaction
retry_lock
subject.transaction
else