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

MigrationChunkClonerSourceOpObserver::onInserts() written to look like it skips checking some documents for whether their chunk has moved

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.1.0-rc0, 7.0.2
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • v7.0
    • Sharding NYC 2023-09-04

      The changes from 0323cbd as part of SERVER-70437 changed the interface of shardObserveInsertOp() to become the plural shardObserveInsertsOp(). However the changes mistakenly copied over the early return inside the for-loop. This turns out not to be a transaction consistency problem in practice because in every version where cross-shard transactions are supported (since MongoDB 4.2), the changes from SERVER-38583 had already made it so onInserts() is only called with a single element at a time.

      We should change the early return to a continue statement to reflect the intended control flow though.

      for (auto it = first; it != last; it++, index++) {
          auto opTime = opTimeList.empty() ? repl::OpTime() : opTimeList[index];
      
          if (inMultiDocumentTransaction) {
              const auto atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime();
      
              if (atClusterTime) {
                  const auto shardKey =
                      metadata->getShardKeyPattern().extractShardKeyFromDocThrows(it->doc);
                  assertIntersectingChunkHasNotMoved(opCtx, *metadata, shardKey, *atClusterTime);
              }
      
              return;
          }
      
          auto cloner = MigrationSourceManager::getCurrentCloner(*csr);
          if (cloner) {
              cloner->onInsertOp(opCtx, it->doc, opTime);
          }
      }
      

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: