[SERVER-2806] fix finalize error message WAS: Database/table creation does not work from getSisterDB in sharded map/reduce (should assert?) Created: 21/Mar/11  Updated: 19/Mar/13  Resolved: 11/Mar/13

Status: Closed
Project: Core Server
Component/s: Internal Code, JavaScript, MapReduce, Sharding
Affects Version/s: 1.8.0-rc2
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Alan Milford Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: Linux
Participants:

 Description   

When running a map/reduce on a sharded collection with a finalize() function, cross-database creation does not work (or assert):

Finalize example (assuming new_db does not yet exist):

finalize = function (key, value) {

var new_db = db.getSisterDB("new_db");
stat = value;
stat._id = key;
new_db.table.save(stat);

return value;
};

In this instance the new_db database is created, but is completely inaccessible and produces inconsistent errors:

> db.getCollectionNames();
Mon Mar 21 15:15:04 uncaught exception: error:

{ "$err" : "no primary!", "code" : 10178 }

> db.repairDatabase();
Mon Mar 21 15:09:00 uncaught exception: error

{ "$err" : "wrong type for BSONElement () 0 != 8", "code" : 13111 }

> db.repairDatabase();
{
"assertion" : "no primary shard configured for db: new_db",
"assertionCode" : 8041,
"errmsg" : "db assertion failure",
"ok" : 0
}

The database also cannot be dropped:

> db.dropDatabase();
{
"assertion" : "assertion client/../s/shard.h:80",
"errmsg" : "db assertion failure",
"ok" : 0
}



 Comments   
Comment by Andy Schwerin [ 11/Mar/13 ]

As of 2.4.0, the "db" object is not even available in map, reduce and finalize methods, to further emphasize that this is not allowed behavior.

Comment by Eliot Horowitz (Inactive) [ 22/Mar/11 ]

Your'e not supposed to write to a db from a finalize at all.

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