Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27288

DocumentSourceSkip and DocumentSourceMatch getNext() should release GetNextResult reference prior to subsequent underlying source getNext() call

    • Fully Compatible
    • ALL
    • Hide

      The following will cause mongod to abort when this issue is present:

      1. Add invariant(false); at the start of the clonedStorage() method in pipeline/document.h
        DocumentStorage& clonedStorage() {
            invariant(false);
            reset(storagePtr()->clone());
            return const_cast<DocumentStorage&>(*storagePtr());
        }
        
      2. Run the following via mongo shell
        For DocumentSourceSkip:
        db.test.insert({x: [1,2,3]})
        db.test.aggregate([{$unwind: {path: "$x"}}, {$skip: 3}]);
        

        For DocumentSourceMatch:

        db.test.insert({x: [1,2,3]})
        db.test.aggregate([{$unwind: {path: "$x"}},{$match: {x: 2}}]);
        
      Show
      The following will cause mongod to abort when this issue is present: Add invariant(false); at the start of the clonedStorage() method in pipeline/document.h DocumentStorage& clonedStorage() { invariant(false); reset(storagePtr()->clone()); return const_cast<DocumentStorage&>(*storagePtr()); } Run the following via mongo shell For DocumentSourceSkip: db.test.insert({x: [1,2,3]}) db.test.aggregate([{$unwind: {path: "$x"}}, {$skip: 3}]); For DocumentSourceMatch: db.test.insert({x: [1,2,3]}) db.test.aggregate([{$unwind: {path: "$x"}},{$match: {x: 2}}]);
    • Query 2017-01-23
    • 0

      Maintaining the reference can lead to unnecessary cloning of data when the underlying source is destructive, as is the case for DocumentSourceUnwind. This leads to a 15% performance degradation in the mongoperf Unwind test.

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: