[SERVER-8173] Mod::isIndexed still not correct for some update edge cases Created: 15/Jan/13  Updated: 11/Jul/16  Resolved: 15/Feb/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Write Ops
Affects Version/s: 2.2.2, 2.3.2
Fix Version/s: 2.4.0-rc1

Type: Bug Priority: Major - P3
Reporter: Thomas Rueckstiess Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-7511 update code does not properly determi... Closed
Operating System: ALL
Participants:

 Description   

Mod::isIndexed still fails to correctly determine if a Mod is indexed with certain indices and fieldNames.

This was originally addressed in SERVER-7511 but missed below edge cases:

// case 1: a.0.b
t = db.jstests_update_arraymatch8;
t.drop();
t.ensureIndex( {'a.0.b': 1} );
t.insert( {'a': [ [ { b:'old' } ] ] } );
assert( t.findOne({'a.0.0.b': 'old'}) );
assert( t.findOne({'a.0.b': 'old'}) );
t.update( {}, {$set: {'a.0.0.b': 'new'}} );
assert( t.findOne({'a.0.b': 'new'}) );
assert( !t.findOne({'a.0.b': 'old'}) );
 
// case 2: a.0.b.c
t = db.jstests_update_arraymatch8;
t.drop();
t.ensureIndex( {'a.0.b.c': 1} );
t.insert( {'a': [ { b:[ { c:'old' } ] } ] } );
assert( t.findOne({'a.0.b.0.c': 'old'}) );
assert( t.findOne({'a.b.0.c': 'old'}) );
assert( t.findOne({'a.0.b.c': 'old'}) );
assert( t.findOne({'a.b.c': 'old'}) );
t.update( {}, {$set: {'a.0.b.0.c': 'new'}} );
assert( t.findOne({'a.0.b.c': 'new'}) );
assert( !t.findOne({'a.0.b.c': 'old'}) );
 
// case 3: a.b.$ref
t = db.jstests_update_arraymatch8;
t.drop();
t.ensureIndex( {'a.b.$ref': 1} );
t.insert( {'a': [ { 'b':{ '$ref':'old', '$id':0 } } ] } );
assert( t.findOne({'a.b.$ref': 'old'}) );
assert( t.findOne({'a.0.b.$ref': 'old'}) );
t.update( {}, {$set: {'a.0.b.$ref': 'new'}} );
assert( t.findOne({'a.b.$ref': 'new'}) );
assert( !t.findOne({'a.b.$ref': 'old'}) );
 
// case 4: a.b and a-b
t = db.jstests_update_arraymatch8;
t.drop();
t.ensureIndex( {'a.b': 1} );
t.ensureIndex( {'a-b': 1} );
t.insert( {'a':{'b':'old'}} );
assert( t.findOne({'a.b': 'old'}) );
t.update( {}, {$set: {'a': {'b': 'new'}}} );
assert( t.findOne({'a.b': 'new'}) );
assert( !t.findOne({'a.b': 'old'}) );

Both 2.2.3-rc0 and 2.3.2 currently fail on these tests.

We should also:

  • Fix this out of bounds std::string read

    if ( ! isdigit( fullName[i+1] ) )
        continue;

  • Audit isIndexed for any other problems.


 Comments   
Comment by auto [ 15/Feb/13 ]

Author:

{u'date': u'2013-02-13T14:56:57Z', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8173: fix other update tests for new ModSet api
Branch: master
https://github.com/mongodb/mongo/commit/da274cac081409d0edb82901b9c1ad9633f9b1aa

Comment by auto [ 15/Feb/13 ]

Author:

{u'date': u'2013-01-28T18:58:11Z', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8173: add a new IndexPathSet class to make checking if a mod will udpate index more reliable
Branch: master
https://github.com/mongodb/mongo/commit/cd299d2c5b00fe869ac0279e7258d352b1bb827e

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