Skip to content

Commit

Permalink
fix some parent issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksclark committed Dec 17, 2022
1 parent 4d90b32 commit c9babda
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sidekiq/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def jobs

begin
if !@existing && !@initialized
parent_bid, Thread.current[:parent_id] = Thread.current[:batch].bid if Thread.current[:batch]
parent_bid = Thread.current[:batch].bid if Thread.current[:batch]

Sidekiq.redis do |r|
r.multi do |pipeline|
Expand All @@ -84,9 +84,11 @@ def jobs
begin
parent = Thread.current[:batch]
Thread.current[:batch] = self
Thread.current[:parent_bid] = parent_bid
yield
ensure
Thread.current[:batch] = parent
Thread.current[:parent_bid] = nil
end

return [] if @queued_jids.size == 0
Expand Down Expand Up @@ -119,7 +121,7 @@ def increment_job_queue(jid)

def conditional_redis_increment!(force=false)
if should_increment? || force
parent_bid = Thread.current[:parent_id]
parent_bid = Thread.current[:parent_bid]
Sidekiq.redis do |r|
r.multi do |pipeline|
if parent_bid
Expand Down

0 comments on commit c9babda

Please sign in to comment.