Commit ecded054 authored by Nick Thomas's avatar Nick Thomas

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
parents a24c484c 133b9f41
---
title: Fix race in forbid_sidekiq_in_transactions.rb
merge_request: 30359
author:
type: fixed
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment