The source project of this merge request has been removed.
Fix transaction pollution in Shard.by_name
What does this MR do?
Per documentation in https://docs.gitlab.com/ee/development/sql.html#find_or_create_by-is-not-atomic
Spotted while reviewing https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23508
Currently, we only use Shard.by_name
in one place, where it is not run inside a transaction. So it's OK. However, in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23508 , we start calling it from within a transaction.
In that case, the raising of ActiveRecord::RecordNotUnique
pollutes the surrounding transaction. For Shard.by_name
to be safe in all cases, we need it to happen within its own new transaction.
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer