diff --git a/lib/que/active_record/connection.rb b/lib/que/active_record/connection.rb index 55ef4965..6212c8b9 100644 --- a/lib/que/active_record/connection.rb +++ b/lib/que/active_record/connection.rb @@ -63,9 +63,9 @@ def clear_active_connections_if_needed!(job) # see https://github.com/que-rb/que/pull/393 return if job.class.resolve_que_setting(:run_synchronously) - # don't clear connections in nested jobs, - # i.e. clear only if this is the outermost instance of - # Que::ActiveRecord::Connection::JobMiddleware + # don't clear connections in nested jobs executed synchronously + # i.e. while we're still inside of the rails executor + # see https://github.com/que-rb/que/pull/412#issuecomment-2194412783 return if Que::ActiveRecord.active_rails_executor? ::ActiveRecord::Base.clear_active_connections!