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

Incorrect scanned Objects in $unionWith operation

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • 4.9.0
    • Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • Query 2021-01-11, Query 2021-01-25

    Description

      scannedObjects in queryExecutor are incorrectly populated for $unionWith operation.

      Current implementation only takes into account the local collection scanned objects and not the objects scanned by $unionWith.

       

      Consider this scenario:

      > db.firstCol.insert({field: 1})
      > db.firstCol.insert({field: 2})
      > db.secondCol.insert({field: 1})
      > db.firstCol.aggregate([{ $unionWith: { coll: "secondCol"}}])

      Output: 

      { "_id" : ObjectId("5fe2f6ad334ad45eff855838"), "field" : 1 }
      { "_id" : ObjectId("5fe2f6b1334ad45eff855839"), "field" : 2 }
      { "_id" : ObjectId("5fe2f6cb334ad45eff85583a"), "field" : 1 }

       

      queryExecutor stats

      >db.serverStatus().metrics.queryExecutor
      { "scanned" : NumberLong(0),
        "scannedObjects" : NumberLong(2),
         "collectionScans" : {
           "nonTailable" : NumberLong(2),
           "total" : NumberLong(2) 
        }
      }
      

       

       We can see scannedObjects is coming out to be 2, but in reality it should be 3.

      We need to fix this, as part of this ticket.

       

      Refer to ticket for similar issue: SERVER-47640

      Attachments

        Activity

          People

            rishab.joshi@mongodb.com Rishab Joshi (Inactive)
            rishab.joshi@mongodb.com Rishab Joshi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: