[SERVER-2199] mapReduce command doesn't tolerate null finalize attribute Created: 09/Dec/10  Updated: 12/Jul/16  Resolved: 16/Jan/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.6.4
Fix Version/s: 1.7.5

Type: Bug Priority: Major - P3
Reporter: Luke Maurer Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

It appears that MR chokes if passed a null finalize function:

> res = db.items.mapReduce(m, r);
{
"result" : "tmp.mr.mapreduce_1291928405_106",
"timeMillis" : 3,
"counts" :

{ "input" : 10, "emit" : 10, "output" : 8 }

,
"ok" : 1,
}
> res = db.items.mapReduce(m, r,

{ finalize: null }

);
Thu Dec 9 13:00:14 uncaught exception: map reduce failed: {
"assertion" : "not code",
"assertionCode" : 10062,
"errmsg" : "db assertion failure",
"ok" : 0
}

The log indicates "can't convert type: 10 to code", which I take to mean MongoDB tried to treat the finalize attribute as code without first checking that it's null.

Note that this is not the behavior of the query attribute:

> res = db.items.mapReduce(m, r,

{ query: null }

);
{
"result" : "tmp.mr.mapreduce_1291928582_108",
"timeMillis" : 33,
"counts" :

{ "input" : 10, "emit" : 10, "output" : 8 }

,
"ok" : 1,
}

Besides simple consistency (and the lack of a more specific error message), it would be nice for MR to be null-safe in finalize because I have some utility code that handles cases both with and without a finalize attribute, and the easy thing is just to pass null as the finalize attribute in cases without it. (I can give illustrative Python code if needed.)



 Comments   
Comment by auto [ 16/Jan/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: handle null finalize in m/r SERVER-2199
https://github.com/mongodb/mongo/commit/418423388cdfbbb6fd6070b418862f56e9b72179

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