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

Mongos does not attach operationTime to the results if the keys are not available

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.11
    • Affects Version/s: None
    • Component/s: Sharding
    • Fully Compatible
    • ALL
    • Sharding 2017-07-31, Sharding 2017-08-21

      Currently mongos does not return operationTime until the signing keys become available. This prevents sessions to be causally consistent as the keys are not available instantaneously.

      Note:
      returning just operationTime even if there are no keys as it does not require keys introduces issues related to a multi-shard execution without gossiping logical time. Its ok for a single RS as it does not need to gossip the clusterTime as its always matches the oplog time

      Suggested implementation will block in mongos initialization until keys are available if its accessing a sharded cluster

      1.
      in initializeSharding: https://github.com/mongodb/mongo/blob/r3.5.10/src/mongo/s/server.cpp#L190
      add a blocking call until keys are available:

      status = waitForSigningKeys(opCtx);
          if (!status.isOK()) {
              return status;
          }
      

      2.
      implement waitForSigningKeys as (very similar to waitForShardRegistryReload)

      Status waitForSigningKeys(OperationContext* opCtx) {
          while (true) {
              auto stopStatus = opCtx->checkForInterruptNoAssert();
              if (!stopStatus.isOK()) {
                  return stopStatus;
              }
      
              try {
                 auto logicalTimeValidator = LogicalTimeValidator::get(opCtx)
                 
                  if (logicalTimeValidator->shouldGossipLogicalTime()) {
                      return Status::OK();
                  }
                  sleepFor(kRetryInterval);
                  continue;
              } catch (const DBException& ex) {
                  Status status = ex.toStatus();
                  warning()
                      << "Error waiting for signing keys, sleeping for 2 seconds and trying again"
                      << causedBy(status);
                  sleepFor(kRetryInterval);
                  continue;
              }
          }
      }
      

            Assignee:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: