Follow-up from "Revert "Merge branch 'deployment-iid-transaction-improvement' into 'master'""
The following discussion from !18827 (closed) should be addressed:
It seems that we should create and retry as early as possible with the
We want to do it to ensure that object is created.
Otherwise the creation of environment will be likely done in big transaction later and I believe that we don't want to do it.
def to_resource find_environment || ::Environment.create(attributes) rescure ActiveRecord::RecordNotUnique retry end
I think we effectively need this.