Remove usage of ExclusiveLease within database transactions

This issue tracks existing usages of ExclusiveLease within database transactions. Existing usage should be an individual issue and assigned to the respective code owner.

The lease-in-transaction checker will be added in !143321 (merged).

File name Description Feature category Issue link
app/mailers/previews/notify_preview.rb The cleanup method wraps the email-generating-block in a transaction code_review_workflow #441523 (closed)
app/models/projects/build_artifacts_size_refresh.rb reset_project_statistics is performed during a transaction which obtains an exclusive lease build_artifacts #441524 (closed)
app/services/ci/retry_job_service.rb ::Ci::Pipelines::AddJobService uses ExclusiveLeaseHelper on a sleeping lock. RetryJobService is called on the drop! state transition which does not run the retry using the after_commit_queue. continuous_integration #441525 (closed)
app/services/users/activity_service.rb Fails spec/features/admin/admin_jobs_spec.rb system test user_profile #441536 (closed)
app/services/issuable_base_service.rb issuable could create a ghost user when updating last_edited_by Users::Internal.ghost will obtain an ExclusiveLease within this transaction team_planning #441526 (closed)
ee/app/workers/work_items/update_parent_objectives_progress_worker.rb The worker obtains an exclusive lease within a ApplicationRecord.transaction team_planning #441527 (closed)
lib/gitlab/counters/buffered_counter.rb commit_increment! updates counters with lease while in a counter_record.transaction build_artifacts #441530 (closed)
lib/gitlab/performance_bar/redis_adapter_when_peek_enabled.rb Fails system spec spec/features/user_can_display_performance_bar_spec.rb. Root cause unknown unknown #441535 (closed)

Status: 11 March 2024

Some issues are being tracked by various teams and prioritised accordingly.

The following issues are not actively being prioritised:

Next steps: ping teams for issues which are not picked-up/prioritised.

Edited by Sylvester Chin