Setting the shard role for secondary namespaces should use the proper dbVersion

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0, 8.2.3
    • Affects Version/s: 8.0.0, 8.1.0, 8.3.0-rc0, 8.2.0
    • Component/s: None
    • None
    • Catalog and Routing
    • Fully Compatible
    • v8.2, v8.0
    • CAR Team 2025-09-29, CAR Team 2025-10-13, CAR Team 2025-10-27, CAR Team 2025-11-10, CAR Team 2025-11-24
    • 2
    • 🟩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, the createScopedShardRoles helper in initialize_auto_get_helper.h sets the dbVersion which is already set on the opCtx. In the case that the main namespace is sharded, though, there is no guarantee that any dbVersion has been set there. We should instead use the dbVersion that is present in the routing information, as this will ensure that we set a dbVersion if any of the collections are unsharded.

      We will need to take special care to handle the cases where

      1. Two namespaces are unsharded - the setShardRole helper does not appreciate recursive calls setting the same dbVersion
      2. Two unsharded namespaces have different ideas of the dbVersion - this could happen if one (or both) of the routing informations are stale

      The effects of this are that when an aggregation involving $lookup runs on a non db-primary shard, if the main collection is tracked-unsharded living on that shard and a secondary collection is untracked-unsharded (thus pertaining to the
      db-primary shard), the non db-primary shard does not install a dbVersion that would ensure validation of the routing info for the secondary collection. Because of that, if the routing info regarding who is the db-primary shard was stale (e.g. shortly following a movePrimary operation), it could happen that the shard incorrectly considers the untracked-unsharded collection as local and incorrectly pushes execution down to SBE, which is incorrect in this case, thus results will be missing.

            Assignee:
            Jordi Serra Torrens
            Reporter:
            Allison Easton
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: