mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Fix flaky spec related to Scheduler::Defer
In some cases in CI env, it seems the AR connection isn’t available and the `ensure` block is executed. It’s calling `#verify!` on the connection, so it can fail sometimes. This is probably why `#clear_active_connections!` was failing too sometimes. Here, we just check the connection is present before clearing the connections.
This commit is contained in:
parent
ef7518d4ad
commit
f69f0211df
@ -136,8 +136,9 @@ module Scheduler
|
|||||||
rescue => ex
|
rescue => ex
|
||||||
Discourse.handle_job_exception(ex, message: "Processing deferred code queue")
|
Discourse.handle_job_exception(ex, message: "Processing deferred code queue")
|
||||||
ensure
|
ensure
|
||||||
ActiveRecord::Base.connection.verify!
|
if ActiveRecord::Base.connection
|
||||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||||
|
end
|
||||||
if start
|
if start
|
||||||
@stats_mutex.synchronize do
|
@stats_mutex.synchronize do
|
||||||
stats = @stats[desc]
|
stats = @stats[desc]
|
||||||
|
Loading…
Reference in New Issue
Block a user