Skip to content

Commit 2af817f

Browse files
committed
minor: fix for refresh with threads test and rs documentation updates
1 parent 5f6544a commit 2af817f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docs/REPLICA_SETS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ The driver will essentially cycle through all known seed addresses until a node
3838
You can now specify a refresh mode and refresh interval for a replica set connection. This will help to ensure that
3939
changes to a replica set's configuration are quickly reflected on the driver side. In particular, if you change
4040
the state of any secondary node, the automated refresh will ensure that this state is recorded on the client side.
41+
42+
There are two secenarios in which refresh is helpful and does not raise exceptions:
43+
44+
# You add a new secondary node to an existing replica set
45+
# You remove an unused secondary from an existing replica set
46+
47+
If using MongoDB earlier than 2.0 any changes to replica set state will raise exceptions therefore refresh mode will not be useful.
48+
4149
If you add a secondary that responds to pings much faster than the existing nodes, then the new secondary will
42-
be used for reads.
50+
be used for reads if :read_preference is :secondary or :secondary_only
4351

4452
Refresh mode is disabled by default.
4553

test/replica_sets/refresh_with_threads_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ def test_read_write_load_with_added_nodes
4545
end
4646
end
4747

48-
@rs.add_node
49-
threads.each {|t| t.join }
48+
# MongoDB < 2.0 will disconnect clients on rs.reconfig()
49+
if @rs.version.first < 2
50+
assert_raise Mongo::ConnectionFailure do
51+
@rs.add_node
52+
threads.each {|t| t.join }
53+
end
54+
else
55+
@rs.add_node
56+
threads.each {|t| t.join }
57+
end
5058

5159
config = @conn['admin'].command({:ismaster => 1})
5260

0 commit comments

Comments
 (0)