diff options
author | Nick Thomas <nick@gitlab.com> | 2019-07-04 16:57:00 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-07-04 16:57:00 +0000 |
commit | ecded054f1b64a39c59777cd8943f97a6c130e01 (patch) | |
tree | 13ffe8d3f284b3b845ce2eb067027711e07062dc /config | |
parent | a24c484cde8de5c526b9d0a11cdec5a8f58b7a7d (diff) | |
parent | 133b9f41088288a53d0b7cca0e9d5bab4a633567 (diff) | |
download | gitlab-ce-ecded054f1b64a39c59777cd8943f97a6c130e01.tar.gz |
Merge branch 'fix-sidekiq-transaction-check-race' into 'master'
Fix race in forbid_sidekiq_in_transactions.rb
Closes #64088
See merge request gitlab-org/gitlab-ce!30359
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/forbid_sidekiq_in_transactions.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/config/initializers/forbid_sidekiq_in_transactions.rb b/config/initializers/forbid_sidekiq_in_transactions.rb index a69f1ba090e..bb190af60b5 100644 --- a/config/initializers/forbid_sidekiq_in_transactions.rb +++ b/config/initializers/forbid_sidekiq_in_transactions.rb @@ -2,15 +2,16 @@ module Sidekiq module Worker EnqueueFromTransactionError = Class.new(StandardError) - 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 + previous_skip_transaction_check = self.skip_transaction_check + Thread.current[:sidekiq_worker_skip_transaction_check] = true yield ensure - self.skip_transaction_check = skip_transaction_check + Thread.current[:sidekiq_worker_skip_transaction_check] = previous_skip_transaction_check + end + + def self.skip_transaction_check + Thread.current[:sidekiq_worker_skip_transaction_check] end module ClassMethods |