Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/models/solid_queue/batch_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def count_new_jobs_among(jobs)

private
def finish_batch
# Every finishing job asks whether it was the last one, and almost never
# is. Asking the cheap question first means the batch row is only read
# for the job that actually finishes the batch. #finish asks it again, so
# this decides nothing on its own.
return if self.class.where(batch_id: batch_id).exists?

# Skip the serialized callback and metadata columns on this hot path
if batch = Batch.select(:id, :finished_at, :enqueued_at).find_by(id: batch_id)
batch.finish
Expand Down