lib/replidog/proxy.rb in replidog-1.0.0 vs lib/replidog/proxy.rb in replidog-1.1.0

- old
+ new

@@ -12,10 +12,11 @@ attr_reader :configuration def initialize(handler, configuration) @handler = handler @configuration = configuration + @lock = Mutex.new end def current_model Thread.current['replidog.current_model'] end @@ -56,10 +57,11 @@ end end def clear_all_slave_connections! slave_connection_pool_table.each_value do |pool| + pool.automatic_reconnect = false pool.disconnect! end end def enable_query_cache! @@ -147,10 +149,12 @@ def raise_connection_not_found raise StandardError, "connection #{current_connection_name} is not found" end def slave_connection_index - index.tap { increment_slave_connection_index } + @lock.synchronize do + index.tap { increment_slave_connection_index } + end end def increment_slave_connection_index self.index = (index + 1) % slave_connection_pool_table.size end