diff --git a/app/models/solid_queue/job_batch.rb b/app/models/solid_queue/job_batch.rb index 58bcee21..fb281fbb 100644 --- a/app/models/solid_queue/job_batch.rb +++ b/app/models/solid_queue/job_batch.rb @@ -11,7 +11,7 @@ class JobBatch < Record class << self def current_batch_id - Thread.current[:current_batch_id] + ActiveSupport::IsolatedExecutionState[:current_batch_id] end def enqueue(attributes = {}) @@ -20,13 +20,13 @@ def enqueue(attributes = {}) job_batch = nil transaction do job_batch = create!(batch_attributes(attributes)) - Thread.current[:current_batch_id] = job_batch.id + ActiveSupport::IsolatedExecutionState[:current_batch_id] = job_batch.id yield end job_batch ensure - Thread.current[:current_batch_id] = previous_batch_id + ActiveSupport::IsolatedExecutionState[:current_batch_id] = previous_batch_id end def dispatch_finished_batches