Transactions roll back when there is contention for resources and/or when you have any kind of integrity issue. That's why you have retries… so no, it is not only something wrong with the input. Something is temporarily wrong with the situation overall.
Those are environmental errors, not programming bugs, and asserting for those conditions is the wrong approach.