diff options
author | Robert Speicher <robert@gitlab.com> | 2017-12-22 17:18:22 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-12-22 17:18:22 +0000 |
commit | 87dbf9846dcc870581ed753c730d768e671c51d4 (patch) | |
tree | c5fbc5bea4912bb1587720c55462702e9e786a58 /config | |
parent | 77d190b4b4ebd78daa965eb4a2ed4a1e3579d956 (diff) | |
parent | 16b8297e77501134cd93a74c3d5c60712930e7fd (diff) | |
download | gitlab-ce-87dbf9846dcc870581ed753c730d768e671c51d4.tar.gz |
Merge branch 'dm-issue-move-transaction-error' into 'master'
Execute project hooks and services after commit when moving an issue
Closes #41324
See merge request gitlab-org/gitlab-ce!16108
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/forbid_sidekiq_in_transactions.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/config/initializers/forbid_sidekiq_in_transactions.rb b/config/initializers/forbid_sidekiq_in_transactions.rb index bedd57ede04..cb611aa21df 100644 --- a/config/initializers/forbid_sidekiq_in_transactions.rb +++ b/config/initializers/forbid_sidekiq_in_transactions.rb @@ -1,5 +1,7 @@ module Sidekiq module Worker + EnqueueFromTransactionError = Class.new(StandardError) + mattr_accessor :skip_transaction_check self.skip_transaction_check = false @@ -12,11 +14,11 @@ module Sidekiq end module ClassMethods - module NoSchedulingFromTransactions + module NoEnqueueingFromTransactions %i(perform_async perform_at perform_in).each do |name| define_method(name) do |*args| if !Sidekiq::Worker.skip_transaction_check && AfterCommitQueue.inside_transaction? - raise <<-MSG.strip_heredoc + raise Sidekiq::Worker::EnqueueFromTransactionError, <<~MSG `#{self}.#{name}` 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. @@ -30,7 +32,7 @@ module Sidekiq end end - prepend NoSchedulingFromTransactions + prepend NoEnqueueingFromTransactions end end end |