[SERVER-6819] "db.ad.find()" from "map" callback, when sharding for collection is enabled Created: 22/Aug/12  Updated: 10/Mar/14  Resolved: 12/Mar/13

Status: Closed
Project: Core Server
Component/s: MapReduce, Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Azat Khuzhin Assignee: Michael Grundy
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

git hash is "9e1a79dc4a2cc632d45e6af67f574c41aeff54ac"


Operating System: ALL
Participants:

 Description   

If you trying to query some additional info from another collection(for example "foo") for "map" callback,
it works only if there is copy of "foo" at every shard, that will run this MR job.

Is it right or not?
Even if you create "Mongo" instance like this "new Mongo('host:port');" ?

Code for reproduce this:

// foo
db.foo.insert({foo: 1});
db.foo.insert({foo: 2});
 
// sharding
sh.enableSharding('current_db');
sh.shardCollection('current_db.barSharded', {_id: 1});
// insert 10m rows
for (var i = 0; i < 10000000; ++i) {
	db.barSharded.insert({i: i});
}
 
var map = function() {                                                                                                                            
	var db = (new Mongo()).getDB(database);
	if (!db.foo.findOne()) {
		throw "reproduced";
	}
}
var reduce = function(rows) {}
 
db.barSharded.mapreduce(map, reduce, {out: "baz"});



 Comments   
Comment by Azat Khuzhin [ 11/Mar/13 ]

I am not trying to do this right now.
I use such code to run MR on all database. (instead of incremental MR)

I've attached git hast to Environment field when I was trying to do this.

Can you catch this?

Comment by Michael Grundy [ 11/Mar/13 ]

Hi -

Are you still trying to run this map-reduce job? If so could you provide the version you are running in your environment? You would not normally be able to create a Mongo() object within the map function.

Thanks!
Mike

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