keysInserted stat incorrect for wildcard indexes when the data contains arrays

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Execution
    • ALL
    • Hide

      The following script reproduces this issue.  It returns 8 instead of the correct 0:

      use wildcard;
      
      db.foo.createIndex(
        { "$**": 1 },
        {
          name: "wildcard_excluding",
          wildcardProjection: {
            f6:  0,
            f7:  0
          }
        }
      );
      
      db.foo.insertOne({
        _id:1,
        f1:  [],
        f2:  [],
        f3:  [],
        f4:  [],
        f5:  [],
        f6:  [],
        f7:  [],
        f8:  [],
        f9:  [],
        f10: []
      });
      
      db.setProfilingLevel(2);
      db.foo.updateOne({_id:1},{$push: {f6:'val61'}});
      db.system.profile.find({ns:'wildcard.foo',op:'update'}).sort({$natural:-1}).limit(1).next().keysInserted 
      Show
      The following script reproduces this issue.  It returns 8 instead of the correct 0: use wildcard; db.foo.createIndex( { "$**" : 1 }, { name: "wildcard_excluding" , wildcardProjection: { f6: 0, f7: 0 } } ); db.foo.insertOne({ _id:1, f1: [], f2: [], f3: [], f4: [], f5: [], f6: [], f7: [], f8: [], f9: [], f10: [] }); db.setProfilingLevel(2); db.foo.updateOne({_id:1},{$push: {f6: 'val61' }}); db.system.profile.find({ns: 'wildcard.foo' ,op: 'update' }).sort({$natural:-1}).limit(1).next().keysInserted
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      in SortedDataIndexAccessMethod::doUpdate(...), numInserted is reported as ticket.added.size() + ticket.newMultikeyMetadataKeys.size().  Both of these data points come from prepareUpdate(...) where ticket.added (and ticket.removed) is calculated based on the diff of ticket.oldKeys and ticket.newKeys.  However, it does not get the old value of ticket.newMultikeyMetadataKeys and does not do a diff, so that value is always set to the total of multikey metadata keys, not the number added.

      We need to get old and new values and do a diff to set this field correctly.

            Assignee:
            Unassigned
            Reporter:
            Logan Karbiner
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: