Class: SolidQueue::BatchExecution
- Defined in:
- app/models/solid_queue/batch_execution.rb
Class Method Summary collapse
Methods inherited from Execution
#discard, discard_all_from_jobs, discard_all_in_batches, execution_data_from_jobs, type, #type
Methods inherited from Record
non_blocking_lock, supports_insert_conflict_target?, use_index, warn_about_pending_migrations
Class Method Details
.create_all_from_jobs(jobs) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/solid_queue/batch_execution.rb', line 15 def create_all_from_jobs(jobs) jobs.select(&:batched?).group_by(&:batch_id).each do |batch_id, jobs_in_batch| # Update the counter first: inserting tracking rows takes a shared FK lock on # the batch row, then incrementing can deadlock concurrent MySQL adders. if attempt_to_update_total_jobs(batch_id, jobs_in_batch) super jobs_in_batch else raise Batch::AlreadyFinished, "Can't add jobs into an already finished batch" end end end |