[SERVER-9441] Secondaries execute distinct/aggregate commands irrespective of slaveOk bit Created: 23/Apr/13  Updated: 11/Jul/16  Resolved: 18/Sep/13

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Replication
Affects Version/s: 2.4.1
Fix Version/s: 2.5.3

Type: Bug Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-10594 slaveOk bit ignored for unsharded ag... Closed
Operating System: ALL
Steps To Reproduce:

I have a test.foo database, which contains a single document, in a replica set. I then connect to a secondary of that replica set in standalone mode:

REPLICASET:SECONDARY> db.runCommand({distinct:"foo",key:"x"})
{
	"values" : [
		NumberLong(1)
	],
	"stats" : {
		"n" : 1,
		"nscanned" : 1,
		"nscannedObjects" : 1,
		"timems" : 0,
		"cursor" : "BasicCursor"
	},
	"ok" : 1
}
 
REPLICASET:SECONDARY> db.runCommand({aggregate:"foo",pipeline:[{$match:{x:1}}]})
{
	"result" : [
		{
			"_id" : ObjectId("5176e98ce84df1db0e30f327"),
			"x" : NumberLong(1)
		}
	],
	"ok" : 1
}

Map/reduce and count commands both fail unless I set slaveOk:

REPLICASET:SECONDARY> db.runCommand({count:"foo"})
{ "errmsg" : "not master", "note" : "from execCommand", "ok" : 0 }
 
REPLICASET:SECONDARY> db.runCommand({mapReduce:"foo",map:function(){},reduce:function(){},out:{inline:true}})
{ "errmsg" : "not master", "note" : "from execCommand", "ok" : 0 }
 
REPLICASET:SECONDARY> rs.slaveOk(true)
 
REPLICASET:SECONDARY> db.runCommand({count:"foo"})
{ "n" : 1, "ok" : 1 }
 
REPLICASET:SECONDARY> db.runCommand({mapReduce:"foo",map:function(){},reduce:function(){},out:{inline:true}})
{
	"results" : [ ],
	"timeMillis" : 17,
	"counts" : {
		"input" : 1,
		"emit" : 0,
		"reduce" : 0,
		"output" : 0
	},
	"ok" : 1
}

Participants:

 Comments   
Comment by auto [ 18/Sep/13 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-9441 do not allow distinct/aggregate without slaveOk
Branch: master
https://github.com/mongodb/mongo/commit/62309f042fd7aee9cbc7be939c3d6b5db695cbfc

Comment by Matt Dannenberg [ 17/Sep/13 ]

not quite, that ticket fixed the case where sharded agg could contact the secondary

contacting a secondary directly still lets your run agg without slaveOk

Comment by Daniel Pasette (Inactive) [ 17/Sep/13 ]

the aggregation portion of this was fixed with SERVER-10594

Comment by Dwight Merriman [ 31/May/13 ]

yeah i guess it shouldn't do that.

Generated at Thu Feb 08 03:20:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.