-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.0
-
Component/s: None
-
None
When the standalone config is empty, e.g., after an error or after stopping the server, on the next insert operation, Cluster#next_primary returns nil and causes errors up the call chain. The cluster.service.scan! call path demonstrates that each server config is updated by the results of the ismaster command, or empty {} for any error.
The following is a possible fix.
class Cluster def next_primary if client.cluster.mode == Mongo::Cluster::Mode::ReplicaSet primary = client.server_preference.primary(servers).first else primary = servers.first end raise Mongo::NoMaster.new("no master") unless primary primary end end
There's probably a better way to fix this via the server_preference mechanism, but at least the above should help to clarify the problem.