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

amend commands for local snapshot in cluster command helpers

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Sharding

      Original Ticket:

      In build(Un)versionedRequestsFor(All)TargetedShards that are used in explains count and distinct
      same thing as in cluster find and aggregate commands - look how it can reuse the code.
      in cluster_commands_helpers.cpp


      Summary:

      Given a BSON command object with readConcern level snapshot, replace its snapshot readConcern with a new snapshot readConcern with atClusterTime. Since the cmd obj already has a readConcern field, the object will be iterated over, copying all of its fields that are not readConcern, then the new readConcern will be appended at the end.

      Details:

      BSONObj appendAtClusterTime(BSONObj cmdObj, LogicalTime atClusterTime) {
          // Append all original fields except the readConcern field to the new command.
          BSONObjBuilder bob;
          for (auto elem : cmdObj) {
              const auto name = elem.fieldNameStringData();
              if (name != "readConcern") {
                  bob.append(elem);
              }
          }
      
          // Add the new snapshot readConcern with atClusterTime.
          BSONObjBuilder readConcernBob(bob.subobjStart("readConcern"));
          readConcernBob.append("level", "snapshot");
          readConcernBob.append("atClusterTime", atClusterTime.asTimestamp());
          readConcernBob.doneFast();
      
          return bob.obj();
      }
      

      Open Questions:

      • Can appendAtClusterTime receive a cmdObj with no readConcern?
        • It should have readConcern: "snapshot" to trigger the GPITR code, so I don't think so.

      Unit tests:

      • Given a BSONObj with each readConcern level, verify appendAtClusterTime overwrites the existing level

      POC: https://mongodbcr.appspot.com/178800002/

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: