Deduplicate cluster listIndexes code by exposing a cluster::listIndexes function

    • Catalog and Routing
    • 🟥 DDL
    • None
    • None
    • None
    • None
    • None
    • None

      loadIndexesFromAuthoritativeShard and the router-level CmdListIndexes::typedRun share nearly identical routing logic (CollectionRoutingInfoTargeter setup, timeseries namespace rewriting, shard selection via minKey chunk, and command execution).

      We should deduplicate by exposing a cluster::listIndexes() function, following the established pattern of cluster::createCollection() and the approach taken in SERVER-123175 for cluster::createIndexes().

      Proposal

      • Add a cluster::listIndexes() function (e.g. in cluster_ddl.h) that encapsulates the shared logic: building the ListIndexes command, handling timeseries namespace rewriting via CollectionRoutingInfoTargeter, selecting the shard owning the minKey chunk (or primary shard for unsharded collections), and executing the command.
      • The new function should accept a parameter controlling whether to drain the full cursor internally (for internal callers like loadIndexesFromAuthoritativeShard) or return a passthrough cursor (for the client-facing command).
      • Refactor CmdListIndexes::typedRun and loadIndexesFromAuthoritativeShard to both delegate to cluster::listIndexes().
      • Current callers of loadIndexesFromAuthoritativeShard (shardsvr_process_interface, mongos_process_interface, rename_collection_coordinator) would switch to the new shared function.

            Assignee:
            Unassigned
            Reporter:
            Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: