Fix error 500s creating projects concurrently
If multiple projects within a group are created concurrently, a
validation error due to duplicate ProjectAuthorization
entries could be
triggered. This can happen due to a race condition: if the user's or group's authorizations get refreshed before the Projects::CreateService
does this, we can get a database unique key violation.
To fix this, we use safe_find_or_create_by!
to ensure that a duplicate
entry doesn't get inserted.
This fixes a regression introduced in GitLab 13.4 via !42335 (merged).
Closes #233862 (closed)
Edited by Stan Hu