Skip to content

Commit 9bbf863

Browse files
committed
Make sure callbacks are not considered part of a batch
* Use enqueue_all directly rather than passing through activejob for completion jobs
1 parent 70149cf commit 9bbf863

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/models/solid_queue/batch_record.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,17 @@ def as_active_job(active_job_klass)
122122

123123
def serialize_callback(value)
124124
return value if value.blank?
125-
as_active_job(value).serialize
125+
active_job = as_active_job(value)
126+
# We can pick up batch ids from context, but callbacks should never be considered a part of the batch
127+
active_job.batch_id = nil
128+
active_job.serialize
126129
end
127130

128131
def perform_completion_job(job_field, attrs)
129132
active_job = ActiveJob::Base.deserialize(send(job_field))
130133
active_job.send(:deserialize_arguments_if_needed)
131134
active_job.arguments = [ Batch.new(_batch_record: self) ] + Array.wrap(active_job.arguments)
132-
ActiveJob.perform_all_later([ active_job ])
135+
SolidQueue::Job.enqueue_all([ active_job ])
133136

134137
active_job.provider_job_id = Job.find_by(active_job_id: active_job.job_id).id
135138
attrs[job_field] = active_job.serialize

0 commit comments

Comments
 (0)