Use `safe_find_or_create_by` to ensure build pending state presence
What does this MR do?
This merge request makes it possible to reduce the noise created by unique constraint violations when ensuring a presence of a build pending state.
Conformity
Issues
Closes #273756 (closed)
Edited by Grzegorz Bizon