Certain mods are considered not to affect index entries that they actually do affect, in particular when the positional operator is used. This can result in index corruption when a document becomes out of sync with its index entries.
Test
c = db.c; [ 'a.b', 'a.0', 'a.0.b' ].forEach( function( indexField ) { c.drop(); indexSpec = {}; indexSpec[ indexField ] = 1; c.ensureIndex( indexSpec ); c.save( { _id:0, a:[ { b:1 } ] } ); c.update( { 'a.b':1 }, { $set:{ 'a.$':{ b:2 } } } ); c.remove( { _id:0 } ); c.find( {} ).hint( indexSpec ).itcount(); } );
Output:
Tue Oct 30 11:46:06 [conn11] unindex failed (key too big?) test.c.$a.0_1 key: { : { b: 2.0 } } _id: 0.0
Tue Oct 30 11:46:06 [conn11] Assertion: 10334:Invalid BSONObj size: -286331154 (0xEEEEEEEE) first element: _id: 0.0
0x10de09165 0x10ddcfe1b 0x10ddb3df3 0x10ddb400a 0x10d71fbac 0x10d70aa9c 0x10d6764c4 0x10d67f3c7 0x10d7ab255 0x10da26fea 0x10da22a3d 0x10da250ec 0x10da28f95 0x10da2dab1 0x10d960832 0x10d965730 0x10d654a67 0x10ddef783 0x10ddf0cc0 0x10ddf0d22
0 mongod 0x000000010de09165 _ZN5mongo15printStackTraceERSo + 37
1 mongod 0x000000010ddcfe1b _ZN5mongo10logContextEPKc + 123
2 mongod 0x000000010ddb3df3 _ZN5mongo11msgassertedEiPKc + 339
3 mongod 0x000000010ddb400a _ZNK5mongo13ExceptionInfo6appendERNS_14BSONObjBuilderEPKcS4_ + 0
4 mongod 0x000000010d71fbac _ZNK5mongo7BSONObj14_assertInvalidEv + 732
5 mongod 0x000000010d70aa9c _ZN5mongo7BSONObj4initEPKc + 76
6 mongod 0x000000010d6764c4 _ZN5mongo7BSONObjC1EPKc + 60
7 mongod 0x000000010d67f3c7 _ZN5mongo7BSONObj4makeEPKNS_6RecordE + 55
8 mongod 0x000000010d7ab255 _ZN5mongo11BtreeCursor7currentEv + 63
9 mongod 0x000000010da26fea _ZNK5mongo21ResponseBuildStrategy7currentEb + 944
10 mongod 0x000000010da22a3d _ZN5mongo20OrderedBuildStrategy11handleMatchERbRNS_12MatchDetailsE + 379
11 mongod 0x000000010da250ec _ZN5mongo20QueryResponseBuilder8addMatchEv + 342
12 mongod 0x000000010da28f95 _ZN5mongo23queryWithQueryOptimizerEiRKSsRKNS_7BSONObjERNS_5CurOpES4_S4_RKN5boost10shared_ptrINS_11ParsedQueryEEES4_RKNS_17ShardChunkVersionERNS7_10scoped_ptrINS_25PageFaultRetryableSectionEEERNSG_INS_19NoPageFaultsAllowedEEERNS_7MessageE + 1893
13 mongod 0x000000010da2dab1 _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 7505
14 mongod 0x000000010d960832 _ZN5mongoL13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 418
15 mongod 0x000000010d965730 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1136
16 mongod 0x000000010d654a67 _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 261
17 mongod 0x000000010ddef783 _ZN5mongo3pms9threadRunEPNS_13MessagingPortE + 2275
18 mongod 0x000000010ddf0cc0 _ZN5boost3_bi5list1INS0_5valueIPN5mongo13MessagingPortEEEEclIPFvS5_ENS0_5list0EEEvNS0_4typeIvEERT_RT0_i + 78
19 mongod 0x000000010ddf0d22 _ZN5boost3_bi6bind_tIvPFvPN5mongo13MessagingPortEENS0_5list1INS0_5valueIS4_EEEEEclEv + 92
Tue Oct 30 11:46:06 [conn11] assertion 10334 Invalid BSONObj size: -286331154 (0xEEEEEEEE) first element: _id: 0.0 ns:test.c query:{ query: {}, $hint: { a.0: 1.0 } }
Tue Oct 30 11:46:06 [conn11] problem detected during query over test.c : { $err: "Invalid BSONObj size: -286331154 (0xEEEEEEEE) first element: _id: 0.0", code: 10334 }
See Mod::isIndexed().
We should also:
- Fix this out of bounds std::string read
if ( ! isdigit( fullName[i+1] ) ) continue;
- Audit isIndexed for any other problems.
- is duplicated by
-
SERVER-8095 Update with positional operator does not update index
- Closed
- related to
-
SERVER-7928 Deleting documents constantly corrupts collection
- Closed
-
SERVER-8173 Mod::isIndexed still not correct for some update edge cases
- Closed