`RepositoryRemoveRemoteWorker.perform_async` being called from transaction
Summary
Sidekiq calling a worker from within a transaction. Similar issue to: https://gitlab.com/gitlab-org/gitlab-ce/issues/35072
Steps to reproduce
Not sure how to reproduce, customer has reported the issue as occurring on one repository.
Example Project
What is the current bug behavior?
500 error and mirror fails to update.
What is the expected correct behavior?
Mirror should update when the sidekiq worker kicks off.
Relevant logs and/or screenshots
Processing by Projects::MirrorsController#update as HTML
Parameters: {(omitted, please see internal issue)}
Completed 500 Internal Server Error in 362ms (ActiveRecord: 38.1ms | Elasticsearch: 0.0ms)
Sidekiq::Worker::EnqueueFromTransactionError (`RepositoryRemoveRemoteWorker.perform_async` cannot be called inside a transaction as this can lead to race conditions when the worker runs before the transaction is committed and tries to access a model that has not been saved yet.
Use an `after_commit` hook, or include `AfterCommitQueue` and use a `run_after_commit` block instead.):
config/initializers/forbid_sidekiq_in_transactions.rb:21:in `block (2 levels) in <module:NoEnqueueingFromTransactions>'
app/models/repository.rb:948:in `async_remove_remote'
lib/gitlab/metrics/instrumentation.rb:159:in `block in async_remove_remote'
lib/gitlab/metrics/method_call.rb:36:in `measure'
lib/gitlab/metrics/instrumentation.rb:159:in `async_remove_remote'
lib/gitlab/i18n.rb:47:in `with_locale'
lib/gitlab/i18n.rb:53:in `with_user_locale'
app/controllers/application_controller.rb:333:in `set_locale'
lib/gitlab/middleware/multipart.rb:95:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:17:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:22:in `call'
lib/gitlab/metrics/rack_middleware.rb:15:in `block in call'
lib/gitlab/metrics/transaction.rb:53:in `run'
lib/gitlab/metrics/rack_middleware.rb:15:in `call'
lib/gitlab/middleware/read_only.rb:31:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
Output of checks
Results of GitLab environment info
Results of GitLab application Check
Possible fixes
Looks related to this commit. @tiagonbotelho would you be able to take a look?
Internal issue: