From 9b6589e033263e28200565c9d36acdf44848b9e4 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Wed, 26 Oct 2011 10:26:50 -0400 Subject: [PATCH] Auto-refresh will be disabled by default. --- docs/REPLICA_SETS.md | 6 +++++- lib/mongo/repl_set_connection.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/REPLICA_SETS.md b/docs/REPLICA_SETS.md index 994655d..cd49055 100644 --- a/docs/REPLICA_SETS.md +++ b/docs/REPLICA_SETS.md @@ -41,7 +41,11 @@ the state of any secondary node, the automated refresh will ensure that this sta If you add a secondary that responds to pings much faster than the existing nodes, then the new secondary will be used for reads. -Refresh mode is enabled in synchronous mode by default. This is the recommended setting, but here's how to specify this explicitly: +Refresh mode is disabled by default. + +However, if you expect to make live changes to your secondaries, and you want this to be reflected without +having to manually restart your app server, then you should enable it. You can enable synchronously, which will +refresh the replica set data in a synchronous fashion (which may ocassionally slow down your queries): @connection = ReplSetConnection.new(['n1.mydb.net', 27017], :refresh_mode => :sync) diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index c1402dd..34cb44e 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -57,7 +57,7 @@ module Mongo # @option opts [Float] :connect_timeout (nil) The number of seconds to wait before timing out a # connection attempt. # @option opts [Boolean] :ssl (false) If true, create the connection to the server using SSL. - # @option opts [Boolean] :refresh_mode (:sync) Set this to :async to enable a background thread that + # @option opts [Boolean] :refresh_mode (false) Set this to :async to enable a background thread that # periodically updates the state of the connection. If, for example, you initially connect while a secondary # is down, this will reconnect to that secondary behind the scenes to # prevent you from having to reconnect manually. If set to :sync, refresh will happen @@ -117,7 +117,7 @@ module Mongo @arbiters = [] # Refresh - @refresh_mode = opts.fetch(:refresh_mode, :sync) + @refresh_mode = opts.fetch(:refresh_mode, false) @refresh_interval = opts[:refresh_interval] || 90 @last_refresh = Time.now