Skip to content
Open
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/job/concurrency_controls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def handle_concurrency_conflict
end

def block
BlockedExecution.create_or_find_by!(job_id: id)
BlockedExecution.create_or_find_by!(job: self)
end

def release_next_blocked_job
Expand Down
2 changes: 1 addition & 1 deletion app/models/solid_queue/job/executable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def discard

private
def ready
ReadyExecution.create_or_find_by!(job_id: id)
ReadyExecution.create_or_find_by!(job: self)
end

def execution
Expand Down
2 changes: 1 addition & 1 deletion app/models/solid_queue/job/schedulable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def scheduled?

private
def schedule
ScheduledExecution.create_or_find_by!(job_id: id)
ScheduledExecution.create_or_find_by!(job: self)
end

def execution
Expand Down
15 changes: 15 additions & 0 deletions test/models/solid_queue/job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ class DiscardableNonOverlappingGroupedJob2 < NonOverlappingJob
)
end

test "enqueue does not reload the job to create its execution" do
job_selects = []
callback = ->(*, payload) { job_selects << payload[:sql] if payload[:sql].match?(/\ASELECT .*solid_queue_jobs/i) }

ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
AddToBufferJob.perform_later(1)
AddToBufferJob.set(wait: 1.minute).perform_later(2)
2.times { NonOverlappingJob.perform_later(@result) }
end

assert SolidQueue::BlockedExecution.exists?

assert_empty job_selects
end

test "enqueue active job to be executed right away" do
active_job = AddToBufferJob.new(1).set(priority: 8, queue: "test")

Expand Down
Loading