FIX: Clear connections before disabling readonly mode.

FIX: Clear connections before disabling readonly mode.

diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
index 7b83711..196eb71 100644
--- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
+++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
@@ -84,9 +84,9 @@ class PostgreSQLFallbackHandler
             if is_connection_active
               logger.warn "#{log_prefix}: Master server is active. Reconnecting..."
               self.master_up(key)
+              clear_connections
               disable_readonly_mode
               Sidekiq.unpause!
-              clear_connections
             end
           rescue => e
             logger.warn "#{log_prefix}: Connection to master PostgreSQL server failed with '#{e.message}'"

GitHub sha: de197000