-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
QE 2023-10-30, QE 2023-11-13
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.
- is related to
-
SERVER-29449 Explain of find command does not transform query for shards
- Backlog
- related to
-
SERVER-32563 explain output for sharded count command is incorrect
- Backlog
-
SERVER-82471 Make sure explain.find issued on mongos sends a modified query to the shards
- Closed