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

change index build initial write timestamp logic

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.1, 4.3.1
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • Labels:
      None
    • Fully Compatible
    • v4.2
    • Execution Team 2019-08-26
    • 69

      The code currently does this to timestamp the initial catalog write for index builds:

             if (opCtx->recoveryUnit()->getCommitTimestamp().isNull() &&
                  replCoord->canAcceptWritesForDatabase(opCtx, "admin")) {
                  // Only primaries must timestamp this write. Secondaries run this from within a
                  // `TimestampBlock`. Primaries performing an index build via `applyOps` may have a
                  // wrapping commit timestamp that will be used instead.
                  opCtx->getServiceContext()->getOpObserver()->onOpMessage(
                      opCtx,
                      BSON("msg" << std::string(str::stream() << "Creating indexes. Coll: " << ns)));
              }
      

      Instead of canAcceptWritesForDatabase(), which incorrectly captures times when a primary is attempting to step down but hasn't yet, we can check for the node state to be STARTUP2; this bit of logic is attempting to differentiate between normal index builds that must be timestamped and index builds that are part of initial sync and must not be timestamped.

            Assignee:
            milkie@mongodb.com Eric Milkie
            Reporter:
            milkie@mongodb.com Eric Milkie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: