[SERVER-9318] Mapreduce implementation call dropCollection for MRInline Created: 11/Apr/13  Updated: 06/Dec/22  Resolved: 18/Jul/16

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

Type: Bug Priority: Major - P3
Reporter: Blake-R Assignee: Backlog - Storage Execution Team
Resolution: Done Votes: 0
Labels: c++, mapreduce
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ArchLinux 3.8.6-1-ARCH
mongodb 2.4.1-2


Issue Links:
Duplicate
duplicates CDRIVER-205 mapreduce command with out:{inline:1}... Closed
Related
Assigned Teams:
Storage Execution
Operating System: Linux
Steps To Reproduce:

Execute an mapreduce command with MRInline object for output argument.

Participants:

 Description   

After last update our mapreduce task was fail with last error "no collection name".
I'm study source and find that dropCollection called in src/mongo/db/commands/mr.cpp from code that refer to https://jira.mongodb.org/browse/SERVER-8234 patch (c0b7158e31d10155a1285f989beae7bb03a5768e).
Strange, but this appear only on C++ driver. Through stack prior user assert is:

Thu Apr 11 10:28:37.217 Backtrace:                                                                                                                                                                                                                                             
0xad7c16 0x6d17f4 0x7f0ba3b17240 0x7f0ba3b171c9 0x7f0ba3b185c8 0x6d129a 0x7f0ba4401b26 0x7f0ba4401b53 0x7f0ba4401dc6 0x719a6c 0x7d3d56 0x7dca02 0x7de386 0x7fd2b8 0x7fdaa2 0x7fe546 0x8ee029 0x8f1524 0x8a48a9 0x6e1b1b                                                        
 build/linux2/normal/mongo/mongod(_ZN5mongo15printStackTraceERSo+0x26) [0xad7c16]                                                                                                                                                                                              
 build/linux2/normal/mongo/mongod(_ZN5mongo10abruptQuitEi+0x254) [0x6d17f4]                                                                                                                                                                                                    
 /usr/lib/libc.so.6(+0x35240) [0x7f0ba3b17240]                                                                                                                                                                                                                                 
 /usr/lib/libc.so.6(gsignal+0x39) [0x7f0ba3b171c9]                                                                                                                                                                                                                             
 /usr/lib/libc.so.6(abort+0x148) [0x7f0ba3b185c8]                                                                                                                                                                                                                              
 build/linux2/normal/mongo/mongod(_ZN5mongo11myterminateEv+0x4a) [0x6d129a]                                                                                                                                                                                                    
 /usr/lib/libstdc++.so.6(+0x5eb26) [0x7f0ba4401b26]                                                                                                                                                                                                                            
 /usr/lib/libstdc++.so.6(+0x5eb53) [0x7f0ba4401b53]                                                                                                                                                                                                                            
 /usr/lib/libstdc++.so.6(__cxa_rethrow+0x46) [0x7f0ba4401dc6]                                                                                                                                                                                                                  
 build/linux2/normal/mongo/mongod(_ZN5mongo20DBClientWithCommands14dropCollectionERKSsPNS_7BSONObjE+0x1ec) [0x719a6c]                                                                                                                                                          
 build/linux2/normal/mongo/mongod(_ZN5mongo2mr5State19dropTempCollectionsEv+0x26) [0x7d3d56]                                                                                                                                                                                   
 build/linux2/normal/mongo/mongod(_ZN5mongo18ScopeGuardImplBase11SafeExecuteINS_18ObjScopeGuardImpl0INS_2mr5StateEMS4_FvvEEEEEvRT_+0x32) [0x7dca02]                                                                                                                            
 build/linux2/normal/mongo/mongod(_ZN5mongo2mr16MapReduceCommand3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0xe06) [0x7de386]                                                                                                                                             
 build/linux2/normal/mongo/mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x28) [0x7fd2b8]                                                                                                                                            
 build/linux2/normal/mongo/mongod(_ZN5mongo7Command11execCommandEPS0_RNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x602) [0x7fdaa2]                                                                                                                                     
 build/linux2/normal/mongo/mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x246) [0x7fe546]                                                                                                                  
 build/linux2/normal/mongo/mongod(_ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x29) [0x8ee029]                                                                                                         
 build/linux2/normal/mongo/mongod(_ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0x6a4) [0x8f1524]                                                                                                                                                          
 build/linux2/normal/mongo/mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0x709) [0x8a48a9]                                                                                                                                              
 build/linux2/normal/mongo/mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0xbb) [0x6e1b1b] 



 Comments   
Comment by Ramon Fernandez Marina [ 18/Jul/16 ]

I'm unable to reproduce this in 3.0.12 or 3.2.8 either.

Comment by Asya Kamsky [ 18/Jul/16 ]

This no longer reproduces in 3.3.9

db.runCommand(  {      mapReduce: 'test.users',      map: mapFunction,      reduce: reduceFunction,      out: { inline: 1 },    } )
{
	"results" : [
		{
			"_id" : "Ethan",
			"value" : 150
		},
		{
			"_id" : "Jacob",
			"value" : 178
		},
		{
			"_id" : "Liam",
			"value" : 165
		},
		{
			"_id" : "Logan",
			"value" : 168
		},
		{
			"_id" : "Mason",
			"value" : 177
		},
		{
			"_id" : "Noah",
			"value" : 162
		}
	],
	"timeMillis" : 5000,
	"counts" : {
		"input" : 1000,
		"emit" : 1000,
		"reduce" : 60,
		"output" : 6
	},
	"ok" : 1
}
test@local:33900(3.3.9) > db.getPrevError()
{ "err" : null, "n" : 0, "nPrev" : -1, "ok" : 1 }

Comment by Thomas Rueckstiess [ 29/Jul/14 ]

This can be reproduced with any map/reduce job that outputs inline. It seems the error fields err and code are set by the non-existent collection drop, but the map/reduce command succeeds and sets ok: 1 without resetting the other fields.

This reproducer script shows the behavior:

var coll = db.test.users;
coll.drop();
 
var names = ["Liam", "Noah", "Ethan", "Mason", "Logan", "Jacob"];
 
for (var i=0; i<1000; i++) {
    coll.insert({name: names[ Math.floor(Math.random() * names.length) ]})
}
 
mapFunction = function () {
    emit(this.name, 1)
}
 
reduceFunction = function(key, values) {
    return Array.sum(values);
}
 
db.resetError()
 
db.runCommand(
   {
     mapReduce: 'test.users',
     map: mapFunction,
     reduce: reduceFunction,
     out: { inline: 1 },
   }
)
 
db.getPrevError()

This results in:

{
	"err" : "no collection name",
	"code" : 10011,
	"n" : 0,
	"nPrev" : 1,
	"ok" : 1
}

Comment by Blake-R [ 05/Jun/14 ]

You right, this error is not ok at all. But it does't affect operation completness check by "ok" field. I think that is answer of cause of ignorance this bug.
Stephen Steneker, can Luis Iñiguez's post reopen ticket for analysis? Think that category will be not only C++.

Comment by Luis Iñiguez [ 05/Jun/14 ]

However, although the "ok" field result is true, I do not understand why this error happens.
This test is from the mongo shell, maybe this is not the right project?

Comment by Blake-R [ 05/Jun/14 ]

Luis Iñiguez, in wich driver? JS output in your and my "getPrevError" - just ok (you should check correctness by "ok" field in db.runCommand result). Trouble was in C++ where request throw exception instead show error or silently ignore it.

Comment by Luis Iñiguez [ 05/Jun/14 ]

I have the same error with the version 2.6.1.

> db.runCommand({mapreduce: "users", map: 'emit(this._id, 1)', reduce: 'function(key, values){return 1;}', out: { inline: 1 } })
{
	"results" : [
		{
			"_id" : ObjectId("63272411b2a3fb401b3a3462"),
			"value" : 1
		}
	],
	"timeMillis" : 1,
	"counts" : {
		"input" : 1,
		"emit" : 1,
		"reduce" : 0,
		"output" : 1
	},
	"ok" : 1
}
> db.getPrevError()
{
	"err" : "no collection name",
	"code" : 10011,
	"n" : 0,
	"nPrev" : 1,
	"ok" : 1
}

Comment by Blake-R [ 17/Mar/14 ]

Acknowledge.

Comment by Stennie Steneker (Inactive) [ 17/Mar/14 ]

Hi,

Please be advised that I'm closing this issue. I apologise that no one has followed up on the issue earlier, but assume that it is no longer relevant given the length of time that has passed.

If you are still seeing this problem, please feel free to reopen with additional information. Ideally we would need the full Map/Reduce code and a sample document to try to reproduce the issue.

Thanks,
Stephen

Comment by Blake-R [ 30/Apr/13 ]

I'm was wrong about other drivers - it's true only without checking last error:

> db.Users.mapReduce(map, reduce, {out:{inline:1}});
{
        "results" : [
                {
                        "_id" : "bank",
                        "value" : 13000
                },
                {
                        "_id" : "cnt",
                        "value" : 13
                }
        ],
        "timeMillis" : 26,
        "counts" : {
                "input" : 13,
                "emit" : 26,
                "reduce" : 2,
                "output" : 2
        },
        "ok" : 1,
}
> db.getPrevError()
{
        "err" : "no collection name",
        "code" : 10011,
        "n" : 0,
        "nPrev" : 1,
        "ok" : 1
}

Comment by Blake-R [ 11/Apr/13 ]

Stack was been gained with change
uassert( 10011 , "no collection name", coll.size() );
to
if (!coll.size()) throw;
in src/mongo/client/dbclientinterface.h.

Comment by Blake-R [ 11/Apr/13 ]

In log our mapreduce task looks thus:

Poker.$cmd { mapreduce: "Users", map: function() { emit('bank', (this.spec_chips || 0) + (this.spec_locked_c..., reduce: function(k, va) { var r = 0; va.forEach(function(v)

{ r += v; }

); return r; }, query: { updated_at:

{ $gte: 1365364800 }

, weeklong_member: true }, out:

{ inline: 1 }

}

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