[SERVER-9249] db object no longer available to mapper Created: 04/Apr/13  Updated: 10/Dec/14  Resolved: 07/Mar/14

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

Type: Bug Priority: Critical - P2
Reporter: Doug Hudson Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.4.1",
"gitVersion" : "1560959e9ce11a693be8b4d0d160d633eee75110",
"sysInfo" : "Linux ip-10-2-29-40 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_49",
"loaderFlags" : "-fPIC -pthread -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -fno-builtin-memcmp -O3",
"allocator" : "tcmalloc",
"versionArray" : [
2,
4,
1,
0
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}

uname -a
Linux djh-lp5 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux


Issue Links:
Related
is related to SERVER-8104 MapReduce on Sharded System Can Bypas... Closed
Operating System: ALL
Steps To Reproduce:

> db.mrtest.save(

{a:1,b:1}

)
> db.other.save(

{x:1,y:1}

)

> m = function ()

{ db.other.findOne(); }

> r = function (k,vaks) { }

> db.mrtest.mapReduce(m, r, 'mrout')
Thu Apr 4 13:58:35.888 JavaScript execution failed: map reduce failed:{
"errmsg" : "exception: JavaScript execution failed: ReferenceError: db is not defined near 'tion () { db.other.fi' ",
"code" : 16722,
"ok" : 0
} at src/mongo/shell/collection.js:L970

Participants:

 Description   

Referencing db in a mapper now raises an exception. The previous version I used 2.2.3 didn't do this.

We rely on this to pull in extra document into when performing map reduces.

A similar change happened some time ago, where the db object was no longer available to finalizers (even though the documentation implied this was valid).



 Comments   
Comment by Asya Kamsky [ 07/Mar/14 ]

This was by design and is described in the release notes for 2.4 as well as the mapreduce reference page.

Comment by Pawel [ 02/May/13 ]

http://stackoverflow.com/questions/16344382/mongo-2-4-making-db-object-available-in-server-side-code-map-reduce

Comment by Carlos Monge [ 02/May/13 ]

Replicated on version 2.4.3

{
	"version" : "2.4.3",
	"gitVersion" : "fe1743177a5ea03e91e0052fb5e2cb2945f6d95f",
	"sysInfo" : "Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49",
	"loaderFlags" : "-fPIC -pthread -rdynamic -m64",
	"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O3 -m64",
	"allocator" : "system",
	"versionArray" : [
		2,
		4,
		3,
		0
	],
	"javascriptEngine" : "V8",
	"bits" : 64,
	"debug" : false,
	"maxBsonObjectSize" : 16777216,
	"ok" : 1
}

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