summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-12-22 11:38:35 +0100
committerDouwe Maan <douwe@selenight.nl>2017-12-22 17:19:50 +0100
commit16b8297e77501134cd93a74c3d5c60712930e7fd (patch)
tree8373c955431ee30156423626a561ca2cf599e47c /config
parent92e15071c13f65cf7250315f1a138284880b0074 (diff)
downloadgitlab-ce-16b8297e77501134cd93a74c3d5c60712930e7fd.tar.gz
Execute project hooks and services after commit when moving an issuedm-issue-move-transaction-error
Diffstat (limited to 'config')
-rw-r--r--config/initializers/forbid_sidekiq_in_transactions.rb8
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