SlaveOk just tells the java driver to prefer the secondaries for reads
but if there are none then the primary will be used.
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>
In general you may want to take the other approach and simply make
sure your writes are going to secondaries so they never get behind.
This will slow down writes but leads to a more consistent view of the
data.
You can also add a feature request to the php driver (in jira) for a
ReadPreference (new name for features like slaveOk) for
maxSecondaryDelay to control this.
On Fri, Jan 6, 2012 at 6:51 PM, Chris <christi...@gmail.com> wrote:
> Hi,
>
> I have a question about replication lag.
> Let say I am using the setSlaveOk in my code (php) and one of my
> slaves is lagging behind by a couple of seconds/minutes.
> How would I know that I should not use the slave(s) for reads? I would
> like to check for lag and all slaves are behind then just not use
> setSlaveOk any suggestions??
>
> Thanks
> Chris
>
> On Jun 28 2011, 3:58 pm, Scott Hernandez <scotthernan...@gmail.com>
> wrote:
>> At each level it is applied to the lower ones, unless overridden. It
>> is an inheritance model. Setting it at the top changes the default
>> from false to true.
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Jun 28, 2011 at 4:34 PM, Zack Radick <zrad...@conducivetech.com> wrote:
>> > Link to the DBCursor API slaveOk entry:
>> >http://api.mongodb.org/java/2.6.3/com/mongodb/DBCursor.html#slaveOk%2...
>>
>> > Setting it on the Mongo instance is global, right?
>> > Cheers,
>> > --Zack
>>
>> > On Tue, Jun 28, 2011 at 1:27 PM, Scott Hernandez <scotthernan...@gmail.com>