is it possible to make query to primary when slaveOk is true

23 views
Skip to first unread message

Sergejs Degtjars

unread,
Aug 1, 2012, 9:05:55 AM8/1/12
to mongodb...@googlegroups.com
I have shareded cluster. My application connects to mongos with slaveOk=true.
I some situation I need to check existence of document with concrete value, and if it isn't present allow to insert new, or deny insert if it exists.
In stress load, we are discovered possibility to get wrong reply to query, because it queries slaves when replication isn't done.

Is there possibility using 10gen C# driver to call MongoCollection.FindOne method with primary node as target?

Thanks.

craiggwilson

unread,
Aug 3, 2012, 10:13:56 AM8/3/12
to mongodb...@googlegroups.com
You cannot call FindOne with a different slave ok value.  However, FindOne is just a helper for Find(...).Limit(1).  Since Find returns a MongoCursor, you can set the slaveOk value there.
Reply all
Reply to author
Forward
0 new messages