Mongo: 2.2.0.
I was seeing exceptions, like the one below. The actual 'bad type' varied - I've seen 49, and 51. That's probably not important.
What I was doing : calling a map/reduce job using Java drivers. To create 'compound' keys for some of the reduced data, I was passing over a character code that would separate the elements of a compound key:
char separator = '\u0000';
scope.put("G_SEPARATOR", (int)separator);
The scope map is passed as scope for M/R job. In JS:
var sep = String.fromCharCode(G_SEPARATOR);
Then certain keys are built with:
key = this.field1 + sep + this.field2;
The special key code is used to prevent clashing character between the separators and the values of the keys.
I don't really know at which point this all breaks. I assume that it breaks when trying to retrieve "G_SEPARATOR" from the global scope, otherwise I don't see how this exception will happen where it happens.
I don know that once I changed the character code to '\0001', things got back to normal. I would expect that there may be some problems with handling strings that have '\0' in them, but this value is passed as an integer, so I don't know.
Anyway, may somebody should take a look into this, and see what may be going on. Let me know if you'd like to me create SSCCE.
Mon Oct 22 11:43:23 [conn2] Assertion: 10320:BSONElement: bad type 49
0x667666 0x621488 0x590b6d 0x8e02a3 0x654847 0x655958 0xa37294 0x83c377 0x848548 0x848c39 0xa57c05 0x8ec7be 0x9d3eb1 0x9ca3be 0x9cb49f 0x9cf894 0x9cfc89 0x9d645d 0xa5d8bc 0xa5f749
/usr/local/bin/mongod(_ZN5mongo15printStackTraceERSo+0x26) [0x667666]
/usr/local/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x98) [0x621488]
/usr/local/bin/mongod(_ZNK5mongo11BSONElement4sizeEv+0x12d) [0x590b6d]
/usr/local/bin/mongod(_ZN5mongo16resolveBSONFieldEP9JSContextP8JSObjectljPS3_+0x133) [0x8e02a3]
/usr/local/bin/mongod(js_LookupPropertyWithFlags+0x1e7) [0x654847]
/usr/local/bin/mongod(js_GetProperty+0x78) [0x655958]
/usr/local/bin/mongod(js_ValueToIterator+0xb4) [0xa37294]
/usr/local/bin/mongod(js_Interpret+0x20c7) [0x83c377]
/usr/local/bin/mongod(js_Invoke+0xab8) [0x848548]
/usr/local/bin/mongod(js_InternalInvoke+0x119) [0x848c39]
/usr/local/bin/mongod(JS_CallFunction+0x25) [0xa57c05]
/usr/local/bin/mongod(_ZN5mongo7SMScope6invokeEP10JSFunctionPKNS_7BSONObjES5_ibbb+0x3ce) [0x8ec7be]
/usr/local/bin/mongod(_ZN5mongo5Scope10invokeSafeEyPKNS_7BSONObjES3_ibbb+0x41) [0x9d3eb1]
/usr/local/bin/mongod(_ZN5mongo2mr9JSReducer7_reduceERKSt6vectorINS_7BSONObjESaIS3_EERS3_Ri+0x7de) [0x9ca3be]
/usr/local/bin/mongod(_ZN5mongo2mr9JSReducer6reduceERKSt6vectorINS_7BSONObjESaIS3_EE+0x6f) [0x9cb49f]
/usr/local/bin/mongod(_ZN5mongo2mr5State14reduceInMemoryEv+0x104) [0x9cf894]
/usr/local/bin/mongod(_ZN5mongo2mr5State9checkSizeEv+0x59) [0x9cfc89]
/usr/local/bin/mongod(_ZN5mongo2mr16MapReduceCommand3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0xb5d) [0x9d645d]
/usr/local/bin/mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRNS_14BSONObjBuilderEb+0x4c) [0xa5d8bc]
/usr/local/bin/mongod(_ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x739) [0xa5f749]
Mon Oct 22 11:43:23 [conn2] JS Error: Error: BSONElement: bad type 49 nofile_b:84
Mon Oct 22 11:43:23 [conn2] warning: ClientCursor::YieldLock not closed properly
Mon Oct 22 11:43:23 [conn2] mr failed, removing collection :: caused by :: 9004 invoke failed: JS Error: Error: BSONElement: bad type 49 nofile_b:84