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

Unify explain and execution path in sharded_agg_helpers

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • 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.

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: