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_id: id) { |e| e.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_id: id) { |e| e.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_id: id) { |e| e.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 @@ -87,6 +87,21 @@ class DiscardableNonOverlappingGroupedJob2 < NonOverlappingJob
assert_equal solid_queue_job.scheduled_at, execution.scheduled_at
end

test "scheduling a single future job does not SELECT the job record back" do
active_job = AddToBufferJob.new(1)
job_selects = 0

subscriber = ->(*, payload) do
job_selects += 1 if payload[:sql].match?(/\ASELECT.*FROM.*solid_queue_jobs/i)
end

ActiveSupport::Notifications.subscribed(subscriber, "sql.active_record") do
SolidQueue::Job.enqueue(active_job, scheduled_at: 5.minutes.from_now)
end

assert_equal 0, job_selects
end

test "enqueue jobs within a connected_to block for the primary DB" do
ShardedRecord.connected_to(role: :writing, shard: :shard_two) do
ShardedJobResult.create!(value: "in shard two")
Expand Down
Loading