Add patch for `find_or_create_by`/`find_or_create_by!`
What does this MR do and why?
This MR adds patch for ActiveRecord find_or_create_by
/find_or_create_by!
methods
so as to prevent it from opening subtransactions. We are patching this via the activerecord-gitlab
gem.
By doing this, we will be unblocking the Rails upgrade in !124004 to version 7.1.1.
Without this patch, the upgrade may lead to repercussions as find_or_create_by
/find_or_create_by!
methods will open subtransactions from then on, and we already have trouble with subtransactions in Postgres - we have documented it here.
Issue: #439567 (closed)
Rails commit that is forcing us to patch the methods: Commit
We are forced to patch this as the above commit introduces calling create_or_find_by
from within find_or_create_by
, and create_or_find_by
internally opens a subtransaction - Source
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.