[SERVER-82218] Unify explain and execution path in sharded_agg_helpers Created: 16/Oct/23  Updated: 17/Nov/23  Resolved: 09/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Ivan Fefer Assignee: Ivan Fefer
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-32563 explain output for sharded count comm... Backlog
related to SERVER-82471 Make sure explain.find issued on mong... Backlog
is related to SERVER-29449 Explain of find command does not tran... Backlog
Backwards Compatibility: Fully Compatible
Sprint: QE 2023-10-30, QE 2023-11-13
Participants:

 Description   

In sharded aggregations, explain() uses slightly different code to target shards than actual execution.

explain() uses scatterGather functions: https://github.com/mongodb/mongo/blob/62b3b9a2d52afeae975c9c6dbb0430c77b72a055/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L1214

This functions re-do the shard targeting, that is already done at this point.

But execution path uses establishShardCursors function that just attaches shard and db version to the remote command and wraps the result into RemoteCursor: https://github.com/mongodb/mongo/blob/62b3b9a2d52afeae975c9c6dbb0430c77b72a055/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L1242

This can lead to differences between explain() output and what actually happens.

We should use a single function to do both things and only do targeting once.

 

Instead of having a separate function to do RemoteCursors and explain commands, we just need a single function to send out requests and a separate function to wrap results in RemoteCursors.



 Comments   
Comment by Githook User [ 09/Nov/23 ]

Author:

{'name': 'Ivan Fefer', 'email': 'ivan.fefer@mongodb.com', 'username': 'Fefer-Ivan'}

Message: SERVER-82218 Unify per shard command creation logic in sharded_agg_helpers.cpp
Branch: master
https://github.com/mongodb/mongo/commit/5da5943203ce822b3491d694b7d46e8d07adb07e

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