Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/models/solid_queue/execution/dispatching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def dispatch_jobs(job_ids)
jobs = Job.where(id: job_ids)

Job.dispatch_all(jobs).map(&:id).tap do |dispatched_job_ids|
where(job_id: dispatched_job_ids).delete_all
where(job_id: dispatched_job_ids).order(:job_id).delete_all
SolidQueue.logger.info("[SolidQueue] Dispatched #{dispatched_job_ids.size} jobs")
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/solid_queue/scheduled_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ScheduledExecution < Execution
include Dispatching

scope :due, -> { where(scheduled_at: ..Time.current) }
scope :ordered, -> { order(scheduled_at: :asc, priority: :asc) }
scope :ordered, -> { order(scheduled_at: :asc, priority: :asc, job_id: :asc) }
scope :next_batch, ->(batch_size) { due.ordered.limit(batch_size) }

assumes_attributes_from_job :scheduled_at
Expand Down
3 changes: 3 additions & 0 deletions test/unit/dispatcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class DispatcherTest < ActiveSupport::TestCase
include ActiveSupport::Testing::MethodCallAssertions

self.use_transactional_tests = false

setup do
@dispatcher = SolidQueue::Dispatcher.new(polling_interval: 0.1, batch_size: 10)
end
Expand Down Expand Up @@ -56,6 +58,7 @@ class DispatcherTest < ActiveSupport::TestCase
assert_equal 15, SolidQueue::ScheduledExecution.count

another_dispatcher = SolidQueue::Dispatcher.new(polling_interval: 0.1, batch_size: 10)

@dispatcher.start
another_dispatcher.start

Expand Down