Skip to content

Fix Members::BaseService to work properly with transactions

What does this MR do?

Fix Members::BaseService to work properly with transactions

We shouldn't schedule Sidekiq jobs directly during service
execution. Instead we should postpone it to after_commit
block where possible.

This will allow running Members services in a transaction without getting Sidekiq::Worker::EnqueueFromTransactionError. E.g.:

ActiveRecord::Base.transaction do
  Members::DestroyService.new(User.last).execute(Member.last)
end

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Edited by Pavel Shutsin

Merge request reports