From 7ca08216bdf6436764a2b8964d06f4bcd84e5eb4 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 30 Oct 2017 14:24:15 +1100 Subject: [PATCH] FIX: ensure we have no dangling db connections on threads This correct 10 second timeouts in dev mode, when reloader kicks in --- config/application.rb | 3 +++ lib/scheduler/defer.rb | 2 ++ plugins/discourse-narrative-bot/plugin.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index e9185f5306b..a0a23106250 100644 --- a/config/application.rb +++ b/config/application.rb @@ -210,6 +210,9 @@ module Discourse # Load plugins 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 # in test mode. see: https://github.com/rails/sprockets-rails/issues/299#issuecomment-167701012 ActiveSupport.on_load(:action_view) do diff --git a/lib/scheduler/defer.rb b/lib/scheduler/defer.rb index 68965f4ae9b..6346b16dae1 100644 --- a/lib/scheduler/defer.rb +++ b/lib/scheduler/defer.rb @@ -74,6 +74,8 @@ module Scheduler end rescue => ex Discourse.handle_job_exception(ex, message: "Processing deferred code queue") + ensure + ActiveRecord::Base.connection_handler.clear_active_connections! end end diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb index 1f2d04984d2..f7524b8b6dc 100644 --- a/plugins/discourse-narrative-bot/plugin.rb +++ b/plugins/discourse-narrative-bot/plugin.rb @@ -32,7 +32,7 @@ after_initialize do ].each { |path| load File.expand_path(path, __FILE__) } # 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'