Handle gitaly calls during transactions in code review workers
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=559090) </details> <!--IssueSummary end--> ## Overview We identified some long idle-in-transaction that are stressing our Postgres connection pools, leaving less space for actual traffic. We identified the following workers as belonging to the ~"group::code review" group: - app/workers/create_note_diff_file_worker.rb - app/workers/delete_diff_files_worker.rb - app/workers/merge_request_cleanup_refs_worker.rb - app/workers/merge_request_mergeability_check_worker.rb - app/workers/merge_requests/mergeability_check_batch_worker.rb - app/workers/merge_requests/update_head_pipeline_worker.rb - app/workers/merge_worker.rb - app/workers/migrate_external_diffs_worker.rb - app/workers/new_merge_request_worker.rb - app/workers/stuck_merge_jobs_worker.rb These workers are executing gitaly calls while keeping DB transactions open. source: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/186758#note_2518140632 ## Deliverables The goal is to not call gitaly from within an open DB transaction, when possible. - [ ] For each worker in the list, move gitaly calls outside database transactions to reduce database pressure.
issue