Skip to content

Commit

Permalink
Attempt to patch MSSQL missing features
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgeorge committed Dec 24, 2023
1 parent 7c6b0d3 commit 47c64ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/solid_queue/blocked_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class BlockedExecution < Execution

class << self
def unblock(count)
expired.distinct.limit(count).pluck(:concurrency_key).then do |concurrency_keys|
release_many releasable(concurrency_keys)
end
# This is probably wrong
rows = expired.distinct.limit(count)
release_many releasable(rows.map(&:concurrency_key))
end

def release_many(concurrency_keys)
Expand Down
7 changes: 6 additions & 1 deletion app/models/solid_queue/claimed_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ class << self
def claiming(job_ids, process_id, &block)
job_data = Array(job_ids).collect { |job_id| { job_id: job_id, process_id: process_id } }

insert_all!(job_data)
if self.connection.supports_insert_on_duplicate_skip?
insert_all!(job_data)
else
job_data.each { |jd| create_with(process_id: jd[:process_id]).find_or_create_by!(job_id: jd[:job_id]) }
end

where(job_id: job_ids, process_id: process_id).load.tap do |claimed|
block.call(claimed)
SolidQueue.logger.info("[SolidQueue] Claimed #{claimed.size} jobs")
Expand Down
12 changes: 11 additions & 1 deletion app/models/solid_queue/scheduled_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ def dispatch_batch(job_ids)
end

def dispatch_at_once(jobs)
ReadyExecution.insert_all ready_rows_from_batch(jobs)
if self.connection.supports_insert_on_duplicate_skip?
ReadyExecution.insert_all ready_rows_from_batch(jobs)
else
ready_rows_from_batch(jobs).each do |job|
ReadyExecution.create_with(
queue_name: job[:queue_name],
priority: job[:priority],
created_at: job[:created_at]
).find_or_create_by(job_id: job[:job_id])
end
end
end

def dispatch_one_by_one(jobs)
Expand Down

0 comments on commit 47c64ed

Please sign in to comment.