Prevent adding topologyVersion twice to command replies

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • CAR Team 2025-06-23, CAR Team 2025-07-07
    • 0
    • None
    • 3
    • TBD
    • 🟦 Shard Catalog
    • None
    • None
    • None
    • None
    • None
    • None

      The appendRawResponses helper is used to aggregate command replies from several shards and attaches the topologyVersion to the main response body.

      When the helper is used in the shard role and a failure needs to be reported (error and/or a write concern error) , the topologyVersion field may be added a second time by appendErrorLabelsAndTopologyVersion.

      Currently, there are just 2 usages of the appendRawResponses in the shard role:

      $ git grep appendRawResponses\( | grep -v test | grep -v cluster_
      
      src/mongo/db/s/collmod_coordinator.cpp:                            bool ok = appendRawResponses(opCtx, &errmsg, &rawBuilder, responses)
      src/mongo/db/s/shardsvr_drop_indexes_command.cpp:            const auto aggregateResponse = appendRawResponses(
      

      Purpose of this ticket is either to account for the fact that the topologyVersion may already have been attached, or to provide an alternative to appendRawResponses helper to be exclusively used in the shard role.

            Assignee:
            Pol Pinol
            Reporter:
            Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: