File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33module Que
44 module ActiveRecord
55 class << self
6- # Use Rails' executor (if present) to make sure that the connection
7- # we're using isn't taken from us while the block runs. See
8- # https://github.com/que-rb/que/issues/166#issuecomment-274218910
96 def wrap_in_rails_executor ( &block )
107 if defined? ( ::Rails . application . executor )
118 ::Rails . application . executor . wrap ( &block )
@@ -21,6 +18,9 @@ class << self
2118
2219 # Check out a PG::Connection object from ActiveRecord's pool.
2320 def checkout
21+ # Use Rails' executor (if present) to make sure that the connection
22+ # we're using isn't taken from us while the block runs. See
23+ # https://github.com/que-rb/que/issues/166#issuecomment-274218910
2424 Que ::ActiveRecord . wrap_in_rails_executor do
2525 ::ActiveRecord ::Base . connection_pool . with_connection do |conn |
2626 yield conn . raw_connection
@@ -32,6 +32,9 @@ def checkout
3232 module JobMiddleware
3333 class << self
3434 def call ( job )
35+ # Use Rails' executor (if present) to make sure that the connection
36+ # used by the job isn't returned to the pool prematurely. See
37+ # https://github.com/que-rb/que/issues/411
3538 Que ::ActiveRecord . wrap_in_rails_executor do
3639 yield
3740 end
You can’t perform that action at this time.
0 commit comments