-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.2
-
Component/s: Command Operations
-
None
Currently the MongoDatabase.runCommand variant that does not take a read preference attempts to select a server that can accept writes (standalone, replica set primary, mongos). But this rules out certain use cases: for example, it will not allow a client to sent a replSetInitiate command to an uninitiated replica set member.
The correct behavior is to allow the command to be sent to a server that is directly connected to using the single ServerAddress MongoClient constructor.
A workaround until this is fixed is to use the runCommand variant that accepts a read preference:
database.runCommand(init, ReadPreference.primary());
Thanks to Jeffrey Phillips Freeman for reporting this in https://groups.google.com/forum/#!topic/mongodb-user/Cy8o4iHG6CU.