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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.0
    • Fix Version/s: 3.4.2, 3.5.2
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      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}}]);
    • Sprint:
      Query 2017-01-23
    • Linked BF Score:
      0

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: