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

Incorrect scanned Objects in $unionWith operation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.9.0
    • Fix Version/s: 4.9.0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      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

          Issue Links

            Activity

              People

              Assignee:
              rishab.joshi Rishab Joshi
              Reporter:
              rishab.joshi Rishab Joshi
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: