clear active connections after each job
in a sharded environment, this helps to clear out idle connections this is similar to what ActiveRecord::ConnectionAdapters::ConnectionManagement middleware does after each web request test plan: * run some jobs * they should not fail Change-Id: I431205ff1e9197940bddf4028d3c4c7662a74056 Reviewed-on: https://gerrit.instructure.com/24285 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
fac171c621
commit
025fbec05e
|
@ -225,8 +225,12 @@ module Delayed
|
|||
# Moved into its own method so that new_relic can trace it.
|
||||
def invoke_job
|
||||
Delayed::Job.in_delayed_job = true
|
||||
payload_object.perform
|
||||
Delayed::Job.in_delayed_job = false
|
||||
begin
|
||||
payload_object.perform
|
||||
ensure
|
||||
Delayed::Job.in_delayed_job = false
|
||||
ActiveRecord::Base.clear_active_connections! unless Rails.env.test?
|
||||
end
|
||||
end
|
||||
|
||||
def batch?
|
||||
|
|
Loading…
Reference in New Issue