[SERVER-8632] System.js functions are not available to map/reduce jobs Created: 20/Feb/13  Updated: 11/Jul/16  Resolved: 27/Feb/13

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: 2.4.0-rc0
Fix Version/s: 2.4.0-rc2

Type: Bug Priority: Major - P3
Reporter: Andre Quina Assignee: Ben Becker
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OSX


Issue Links:
Related
related to SERVER-8773 Write automated tests for stored proc... Closed
related to SERVER-9739 Stored JavaScript fails when starting... Closed
Operating System: ALL
Steps To Reproduce:

In 2.4.0-rc0:

> db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }});
> db.records.insert(

{foo:'bar'}

)
> db.records.mapReduce(function()

{ sum(1,2) },function() {}, {out: 'test_mr_out'});
Wed Feb 20 10:21:53.844 map reduce failed:{
"errmsg" : "exception: map invoke failed: ReferenceError: sum is not defined _funcs1:1",
"code" : 9014,
"ok" : 0
} src/mongo/shell/collection.js:939

In 2.2.0:

> db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }});
> db.records.insert({foo:'bar'})
> db.records.mapReduce(function() { sum(1,2) }

,function() {},

{out: 'test_mr_out'}

);
{
"result" : "test_mr_out",
"timeMillis" : 59,
"counts" :

{ "input" : 36, "emit" : 0, "reduce" : 0, "output" : 0 }

,
"ok" : 1,
}

Participants:

 Description   

It does not appear that functions defined in system.js are available to map reduce jobs in 2.4.0-rc0. In 2.2.0 and before these functions were available. Without the ability to add functions to system.js for map reduce jobs, jobs with common functionality or that rely on JS libraries become unmanageable. Also, the full jobs must be sent to the server rather than simply calling a function defined in system.js



 Comments   
Comment by auto [ 27/Feb/13 ]

Author:

{u'date': u'2013-02-27T21:03:29Z', u'name': u'Ben Becker', u'email': u'ben.becker@10gen.com'}

Message: SERVER-8632: fix server-side JS for MapReduce, $where and group
Branch: master
https://github.com/mongodb/mongo/commit/5eb8129fe56f7ef5454577416ac8b4fc12e2ae46

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