-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.2
-
Component/s: None
mongoDB Setup
Replica Set with all secondaries, no primary is up.
Sample Code:
var server = MongoServer.Create(ConfigurationManager.AppSettings["connectionString"]);
var db = server.GetDatabase("myDb", SafeMode.False);var settings = db.CreateCollectionSettings<Task>("Tasks");
settings.SlaveOk = true;
settings.SafeMode = SafeMode.False;var taskCollection = db.GetCollection(settings);
var tasks = taskCollection.FindAll();
var taskCount = taskCollection.Count();
I can get the collection of items fine from taskCollection.FindAll(), but if I call taskCollection.Count(), driver throws the following error:
MongoDB.Driver.MongoConnectionException: Unable to connect to the primary member of the replica set: No connection could be made because the target machine actively refused it
Some troubleshooting leads me to believe the MongoCollection.Count() implementation is not respecting the SlaveOk setting.
- is related to
-
CSHARP-336 Add support for sending commands to secondaries when slaveOk is true
- Closed