[SERVER-50246] $unionWith explain loses information from any stages in sub-pipeline which get absorbed into cursor stage Created: 11/Aug/20  Updated: 29/Oct/23  Resolved: 08/Sep/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.7.0, 4.4.2

Type: Bug Priority: Major - P3
Reporter: Ted Tuckman Assignee: Nicholas Zolnierz
Resolution: Fixed Votes: 0
Labels: qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
causes SERVER-50895 $unionWith cached pipeline for explai... Closed
causes SERVER-58888 $unionWith explain with mode "executi... Closed
Related
related to SERVER-50597 Explain against a pipeline containing... Backlog
related to SERVER-22622 Improve $lookup explain to indicate q... Needs Scheduling
is related to SERVER-49469 explain executionStats for $unionWith... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4
Sprint: Query 2020-09-07, Query 2020-09-21
Participants:
Linked BF Score: 0

 Description   

When we explain a pipeline with mode "executionStats" or above, we first execute the pipeline to completion and then serialize the individual stages. If one of those stages is a $unionWith, then the first phase will target and optimize the sub-pipeline, absorbing any possible stages into the $cursor stage. When serialize() is subsequently called against the $unionWith to generate the 'stages' element of explain, we do the same process again except we've lost any stages which were pushed down into the $cursor/$mergeCursors.



 Comments   
Comment by Githook User [ 16/Sep/20 ]

Author:

{'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com', 'username': 'nzolnierzmdb'}

Message: SERVER-50246 Fix $unionWith explain with mode 'executionStats' to account for pushed down stages

(cherry picked from commit 4edfad49d10c3f75cf1fbc2f909e424d79f4a7e1)
Branch: v4.4
https://github.com/mongodb/mongo/commit/95f19f434bbbccba3723fe84c59f1644465a5a7a

Comment by Githook User [ 08/Sep/20 ]

Author:

{'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com', 'username': 'nzolnierzmdb'}

Message: SERVER-50246 Fix $unionWith explain with mode 'executionStats' to account for pushed down stages
Branch: master
https://github.com/mongodb/mongo/commit/4edfad49d10c3f75cf1fbc2f909e424d79f4a7e1

Comment by Nicholas Zolnierz [ 01/Sep/20 ]

Marking as related to SERVER-22622, as they share a common theme of explaining pipelines which read/access multiple collections.

Comment by Nicholas Zolnierz [ 24/Aug/20 ]

Re-titled to describe the issue. When we explain a pipeline with mode "executionStats" or above, we first execute the pipeline to completion and then serialize the individual stages. If one of those stages is a $unionWith, then the first phase will target and optimize the sub-pipeline, absorbing any possible stages into the $cursor stage. When serialize() is subsequently called against the $unionWith, we do the same process again except we lose any stages which were pushed down.

In the test added by SERVER-49469, the sub-pipeline has a $match stage which is lost when $unionWith serialize() is called.

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