[SERVER-1263] setSlaveOk has no effect with group() queries Created: 21/Jun/10  Updated: 29/May/12  Resolved: 05/Jan/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.4.1, 1.4.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: David Mytton Assignee: Antoine Girbal
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Sun May 23 16:25:17 db version v1.4.1, pdfile version 4.5
Sun May 23 16:25:17 git version: 5b29dec9707d50979c283057ca1b1572351eef9a
Sun May 23 16:25:17 sys info: Linux domU-12-31-39-06-79-A1 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41

and

Wed Jun 9 19:27:44 db version v1.4.3, pdfile version 4.5
Wed Jun 9 19:27:44 git version: 47ffbdfd53f46edeb6ff54bbb734783db7abc8ca
Wed Jun 9 19:27:44 sys info: Linux domU-12-31-39-06-79-A1 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41


Issue Links:
Depends
Operating System: ALL
Participants:

 Description   

Executing db.getMongo().setSlaveOk() allows me to run a map reduce query on a replica pair slave but the equivalent group() query does not work. Reproduced on v1.4.1 and v1.4.3.

Master:

> db.sd_boxedice_checksLoadAvrg.group(
... {
... initial:

{count: 0, running_average: 0}

,
... reduce: function(doc, out)
...

{ ... out.count++; ... out.running_average+=doc.v; ... },
... finalize: function(out)
... { ... out.average = out.running_average / out.count; ... }
... }
... );
[
{ "count" : 204931, "running_average" : 131253.02999999493, "average" : 0.6404742571889803 }
]

Slave


> db.sd_boxedice_checksLoadAvrg.group(
... {
... initial: {count: 0, running_average: 0},
... reduce: function(doc, out)
... {... out.count++;... out.running_average+=doc.v;... }

,
... finalize: function(out)
...

{ ... out.average = out.running_average / out.count; ... }

... }
... );
[

{ "count" : 1, "running_average" : NaN, "average" : NaN }

]



 Comments   
Comment by Antoine Girbal [ 05/Jan/11 ]

this is covered by SERVER-2286

Comment by Eliot Horowitz (Inactive) [ 21/Dec/10 ]

Was that as a replica set?
THe best test would be bring up a 3 node replica set.
Run against a secondary
without SLAVE_OK should fail
with SLAVE_OK should work

Comment by Antoine Girbal [ 21/Dec/10 ]

I am not able to reproduce the issue.
I started 1 mongod on 27017 as master, and 1 mongod on 27018 as slave.
Then connected client to to 27018 and killed master mongod.
I was still able to run group queries on the slave:

> db.test.find()

{ "_id" : ObjectId("4d112911220ecff98cc83d96"), "a" : 1 } { "_id" : ObjectId("4d11291f220ecff98cc83d97"), "a" : 2 }

> db.test.group({
... initial:

{count: 0}

,
... reduce: function(obj,out)

{ ... out.count++; ... }

,
... finalize: function(out)

{ ... out.count *= 10; ... }

... })
[

{ "count" : 20 }

]
> db.test.insert(

{b:1}

)
not master
>

Comment by Dwight Merriman [ 05/Nov/10 ]

replica pairs are deprecated so i would propose we close this as "wrong but will not fix".

Generated at Thu Feb 08 02:56:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.