FIX: ensure we have no dangling db connections on threads

This correct 10 second timeouts in dev mode, when reloader kicks in
This commit is contained in:
Sam 2017-10-30 14:24:15 +11:00
parent da72ecc3fc
commit 7ca08216bd
3 changed files with 6 additions and 1 deletions

View File

@ -210,6 +210,9 @@ module Discourse
# Load plugins # Load plugins
Discourse.plugins.each(&:notify_after_initialize) Discourse.plugins.each(&:notify_after_initialize)
# we got to clear the pool in case plugins connect
ActiveRecord::Base.connection_handler.clear_active_connections!
# This nasty hack is required for not precompiling QUnit assets # This nasty hack is required for not precompiling QUnit assets
# in test mode. see: https://github.com/rails/sprockets-rails/issues/299#issuecomment-167701012 # in test mode. see: https://github.com/rails/sprockets-rails/issues/299#issuecomment-167701012
ActiveSupport.on_load(:action_view) do ActiveSupport.on_load(:action_view) do

View File

@ -74,6 +74,8 @@ module Scheduler
end end
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
ActiveRecord::Base.connection_handler.clear_active_connections!
end end
end end

View File

@ -32,7 +32,7 @@ after_initialize do
].each { |path| load File.expand_path(path, __FILE__) } ].each { |path| load File.expand_path(path, __FILE__) }
# Disable welcome message because that is what the bot is supposed to replace. # Disable welcome message because that is what the bot is supposed to replace.
SiteSetting.send_welcome_message = false SiteSetting.send_welcome_message = false if SiteSetting.send_welcome_message
require_dependency 'plugin_store' require_dependency 'plugin_store'