From 2af817f0f8c99d0e348c4425c7470c1feb5af7b8 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Wed, 7 Mar 2012 16:38:14 -0500 Subject: [PATCH] minor: fix for refresh with threads test and rs documentation updates --- docs/REPLICA_SETS.md | 10 +++++++++- test/replica_sets/refresh_with_threads_test.rb | 12 ++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/REPLICA_SETS.md b/docs/REPLICA_SETS.md index c6a1ca3..c401e9f 100644 --- a/docs/REPLICA_SETS.md +++ b/docs/REPLICA_SETS.md @@ -38,8 +38,16 @@ The driver will essentially cycle through all known seed addresses until a node You can now specify a refresh mode and refresh interval for a replica set connection. This will help to ensure that changes to a replica set's configuration are quickly reflected on the driver side. In particular, if you change the state of any secondary node, the automated refresh will ensure that this state is recorded on the client side. + +There are two secenarios in which refresh is helpful and does not raise exceptions: + +# You add a new secondary node to an existing replica set +# You remove an unused secondary from an existing replica set + +If using MongoDB earlier than 2.0 any changes to replica set state will raise exceptions therefore refresh mode will not be useful. + If you add a secondary that responds to pings much faster than the existing nodes, then the new secondary will -be used for reads. +be used for reads if :read_preference is :secondary or :secondary_only Refresh mode is disabled by default. diff --git a/test/replica_sets/refresh_with_threads_test.rb b/test/replica_sets/refresh_with_threads_test.rb index 458bb06..db5d6c3 100644 --- a/test/replica_sets/refresh_with_threads_test.rb +++ b/test/replica_sets/refresh_with_threads_test.rb @@ -45,8 +45,16 @@ class ReplicaSetRefreshWithThreadsTest < Test::Unit::TestCase end end - @rs.add_node - threads.each {|t| t.join } + # MongoDB < 2.0 will disconnect clients on rs.reconfig() + if @rs.version.first < 2 + assert_raise Mongo::ConnectionFailure do + @rs.add_node + threads.each {|t| t.join } + end + else + @rs.add_node + threads.each {|t| t.join } + end config = @conn['admin'].command({:ismaster => 1})