DEV: Only failover the entire cluster when the default db goes down.

DEV: Only failover the entire cluster when the default db goes down.

diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb
index 99def93..5e783de 100644
--- a/config/initializers/002-rails_failover.rb
+++ b/config/initializers/002-rails_failover.rb
@@ -31,9 +31,11 @@ if defined?(RailsFailover::ActiveRecord)
   end
 
   RailsFailover::ActiveRecord.on_failover do
-    RailsMultisite::ConnectionManagement.each_connection do
-      Discourse.enable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
-      Sidekiq.pause!("pg_failover") if !Sidekiq.paused?
+    if RailsMultisite::ConnectionManagement.current_db = RailsMultisite::ConnectionManagement::DEFAULT
+      RailsMultisite::ConnectionManagement.each_connection do
+        Discourse.enable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
+        Sidekiq.pause!("pg_failover") if !Sidekiq.paused?
+      end
     end
   end
 

GitHub sha: d5c56a84

1 Like