[SERVER-53501] Incorrect scanned Objects in $unionWith operation Created: 23/Dec/20  Updated: 29/Oct/23  Resolved: 21/Jan/21

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 4.9.0
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Rishab Joshi (Inactive) Assignee: Rishab Joshi (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-53771 $facet should report its summary stats Closed
is related to SERVER-47640 $lookup should increment the serverSt... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2021-01-11, Query 2021-01-25
Participants:

 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



 Comments   
Comment by Githook User [ 21/Jan/21 ]

Author:

{'name': 'Rishab Joshi', 'email': 'rishab.joshi@mongodb.com'}

Message: SERVER-53501 Fix incorrect reporting of scannedObjects in serverStatus() for $unionWith operation
Branch: master
https://github.com/mongodb/mongo/commit/85d80999474d32b812d2c8519e1fe5398b1850b3

Comment by Rishab Joshi (Inactive) [ 12/Jan/21 ]

CR: https://mongodbcr.appspot.com/740800035/

Generated at Thu Feb 08 05:31:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.