Google Groups

Re: [mongodb-user] Re: SlaveOk queries doesn't seems to go through mongoS

Randolph Tan Apr 4, 2012 1:40 PM
Posted in group: mongodb-user
Are you still having this issue? I am struggling to reproduce this bug. Do you have a verbose logs of the replicas that corresponds to the same time frame with the verbose mongos log that is experiencing this issue?

On Thursday, March 29, 2012 3:27:40 PM UTC-4, Simon T. wrote:
The problem is indeed persistent, I never could get the queries to be redirected to the secondary while passing by the mongos.

The scripts are very simple: it is just looping queries. Here is two examples that does the same thing, one in java and the other one in C#:

try {
Mongo _mongo = new Mongo("osmngs01", 27017);
DB db = _mongo.getDB("AAAAA");
if (db.authenticate("XXXXXXX", "YYYYYYYY".toCharArray()) == false) {
String message = String.format("Initialization Error: Failed to authenticate to %1$s.", "osmngs01");

DBCollection coll = db.getCollection("players");
for(int i=0;i<10000;i++)
DBObject player = coll.findOne(new BasicDBObject("s_nintendoID", Integer.toString(i)));

System.out.println("index: " + i + " players: " + player);

} catch (UnknownHostException ex) {
String message = String.format("Initialization Error: Host %1$s does not exists. Message: %2$s",
"osmngs01", ex.getMessage());
} catch (MongoException ex) {
String message = String.format("Initialization Error: Cannot connect to host %1$s:%2$s. Message: %3$s",
"osmngs01", 27017, ex.getMessage());


string connectionString = "mongodb://XXXXX:YYYYY@osmngs01/?slaveOk=true";
MongoServer mongoServer = MongoServer.Create(connectionString);
MongoDatabase mongoDB = mongoServer.GetDatabase(MONGO_DB);
MongoCollection<BsonDocument> documents = mongoDB.GetCollection("players");
Random rndNb = new Random();
for (int i = 0; i < 15000; i++)
int iPlayer = rndNb.Next(1, 400000);
var query = Query.EQ("s_nintendoID", iPlayer.ToString());

BsonDocument bsonPlayer = documents.FindOne(query);

catch (Exception exc)