Skip to content

Commit

Permalink
do not override checkout adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ankithads committed Aug 8, 2024
1 parent 22eca7b commit 5cc592f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lib/que/adapters/active_record_with_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,10 @@ def initialize(job_connection_pool:, lock_connection_pool:)
super
end

def checkout
def checkout_activerecord_adapter(&block)
checkout_lock_database_connection do
checkout_activerecord_adapter { |conn| yield conn.raw_connection }
@job_connection_pool.with_connection(&block)
end
rescue *AR_UNAVAILABLE_CONNECTION_ERRORS => e
raise UnavailableConnection, e
rescue ::ActiveRecord::StatementInvalid => e
raise e unless AR_UNAVAILABLE_CONNECTION_ERRORS.include?(e.cause.class)

# ActiveRecord::StatementInvalid is one of the most generic exceptions AR can
# raise, so we catch it and only handle the specific nested exceptions.
raise UnavailableConnection, e.cause
end

def checkout_activerecord_adapter(&block)
@job_connection_pool.with_connection(&block)
end

def checkout_lock_database_connection(&block)
Expand Down

0 comments on commit 5cc592f

Please sign in to comment.