diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-02 12:12:08 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-06-02 12:37:57 -0500 |
commit | 103b5bf60ba952e661b3e22d866cc64eed7358ee (patch) | |
tree | 409e692f6891efe96857386f48e8da1a3f3ef5d0 /config | |
parent | e4eac1fff1ba6d890f9f028dbfe47918b7876688 (diff) | |
download | gitlab-ce-103b5bf60ba952e661b3e22d866cc64eed7358ee.tar.gz |
Fix keys seed
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/forbid_sidekiq_in_transactions.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/config/initializers/forbid_sidekiq_in_transactions.rb b/config/initializers/forbid_sidekiq_in_transactions.rb index b22fb33748d..a78711fe599 100644 --- a/config/initializers/forbid_sidekiq_in_transactions.rb +++ b/config/initializers/forbid_sidekiq_in_transactions.rb @@ -1,7 +1,15 @@ module Sidekiq module Worker - mattr_accessor :inside_after_commit - self.inside_after_commit = false + mattr_accessor :skip_transaction_check + self.skip_transaction_check = false + + def self.skipping_transaction_check(&block) + skip_transaction_check = self.skip_transaction_check + self.skip_transaction_check = true + yield + ensure + self.skip_transaction_check = skip_transaction_check + end module ClassMethods module NoSchedulingFromTransactions @@ -9,7 +17,7 @@ module Sidekiq %i(perform_async perform_at perform_in).each do |name| define_method(name) do |*args| - return super(*args) if Sidekiq::Worker.inside_after_commit + return super(*args) if Sidekiq::Worker.skip_transaction_check return super(*args) unless ActiveRecord::Base.connection.open_transactions > NESTING raise <<-MSG.strip_heredoc @@ -30,16 +38,12 @@ end module ActiveRecord class Base - module InsideAfterCommit + module SkipTransactionCheckAfterCommit def committed!(*) - inside_after_commit = Sidekiq::Worker.inside_after_commit - Sidekiq::Worker.inside_after_commit = true - super - ensure - Sidekiq::Worker.inside_after_commit = inside_after_commit + Sidekiq::Worker.skipping_transaction_check { super } end end - prepend InsideAfterCommit + prepend SkipTransactionCheckAfterCommit end end |