<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Replica Set Data Synchronization
  <a class="headerlink leafygreen-ui-1kepx47" href="#replica-set-data-synchronization" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="replica-set-data-synchronization">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#initial-sync" target="_self">
     <span>
      Initial Sync
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#replication" target="_self">
     <span>
      Replication
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  To maintain up-to-date copies of the shared data set,
secondary members of a replica set
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sync">
   sync
  </a>
  or replicate data from a
  <!-- -->
  source member
  <!-- -->
  . MongoDB uses two forms of data synchronization:
initial sync to populate new members
with the full data set, and replication to apply ongoing changes to the
entire data set.
 </p>
 <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-initial-sync">
 </span>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Initial Sync
   <a class="headerlink leafygreen-ui-1kepx47" href="#initial-sync" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="initial-sync">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Initial sync copies all the data from the
   <!-- -->
   source member
   <!-- -->
   of the replica set to
a
   <!-- -->
   destination member
   <!-- -->
   . See
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-initial-sync-source-selection" target="_self">
    <span>
     Initial Sync Source Selection
    </span>
   </a>
   for
more information on
   <!-- -->
   source member
   <!-- -->
   selection criteria.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   The
   <code class="leafygreen-ui-1l06pbn">
    local
   </code>
   database stores the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog">
    oplog
   </a>
   data that the initial
sync process uses. Ensure the
   <!-- -->
   destination member
   <!-- -->
   has enough space in the
   <code class="leafygreen-ui-1l06pbn">
    local
   </code>
   database to store the oplog data for the initial sync process to
complete.
  </p>
  <div class="leafygreen-ui-15mdk4" role="note">
   <h2 class="leafygreen-ui-6n7b7d">
    Note
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     During the initial sync, MongoDB truncates the oplog on the
     <!-- -->
     destination member
     <!-- -->
     . This
oplog truncation can impact processes, such as
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams">
      change streams
     </a>
     , that depend on oplog data.
    </p>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   You can specify the preferred initial sync source using the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
    <code class="leafygreen-ui-1l06pbn">
     initialSyncSourceReadPreference
    </code>
   </a>
   parameter. This parameter can
only be specified when starting the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
    .
   </a>
  </p>
  <p class="leafygreen-ui-1kp3ins">
   Starting in MongoDB 5.2, initial syncs can be
   <em>
    logical
   </em>
   or
   <em>
    file copy
based
   </em>
   .
  </p>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-initial-sync-logical">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Logical Initial Sync Process
    <a class="headerlink leafygreen-ui-1kepx47" href="#logical-initial-sync-process" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="logical-initial-sync-process">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    When you perform a logical initial sync, MongoDB:
   </p>
   <ol class="leafygreen-ui-rioki0" type="1">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Clones all databases except the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/local-database/#std-label-replica-set-local-database">
       local
      </a>
      database. To clone, the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
       <code class="leafygreen-ui-1l06pbn">
        mongod
       </code>
      </a>
      scans every collection in each
      <!-- -->
      source member
      <!-- -->
      database and inserts all data into its own copies of these
collections.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Builds all collection indexes as the documents are copied for each
collection.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Pulls newly added oplog records during the data copy. Ensure that the
      <!-- -->
      destination member
      <!-- -->
      has enough disk space in the
      <code class="leafygreen-ui-1l06pbn">
       local
      </code>
      database to temporarily store these oplog records for the duration of
this data copy stage.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Applies all changes to the data set. Using the oplog from the
      <!-- -->
      source member
      <!-- -->
      , the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
       <code class="leafygreen-ui-1l06pbn">
        mongod
       </code>
      </a>
      updates its data set to reflect
the current state of the replica set.
     </p>
    </li>
   </ol>
   <p class="leafygreen-ui-1kp3ins">
    When the initial sync finishes, the member transitions from
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.STARTUP2">
     <code class="leafygreen-ui-1l06pbn">
      STARTUP2
     </code>
    </a>
    to
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY">
     <code class="leafygreen-ui-1l06pbn">
      SECONDARY
     </code>
     .
    </a>
   </p>
   <p class="leafygreen-ui-1kp3ins">
    To perform an initial sync, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/resync-replica-set-member/#std-label-resync-replica-member">
     Resync a Member of a Self-Managed Replica Set
     <!-- -->
     .
    </a>
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-initial-sync-file-copy-based">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    File Copy Based Initial Sync
    <a class="headerlink leafygreen-ui-1kepx47" href="#file-copy-based-initial-sync" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="file-copy-based-initial-sync">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    <em>
     Available in MongoDB Enterprise only.
    </em>
   </p>
   <p class="leafygreen-ui-1kp3ins">
    File copy based initial sync runs the initial sync process by copying
and moving files on the file system. This sync method can be faster than
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-initial-sync-logical" target="_self">
     <span>
      logical initial sync
      <!-- -->
      .
     </span>
    </a>
   </p>
   <div class="leafygreen-ui-85da11" role="note">
    <h2 class="leafygreen-ui-1ac4g5h">
     Important
    </h2>
    <h3 class="leafygreen-ui-144d5kf">
     <strong>
      File copy based initial sync may cause inaccurate counts
     </strong>
    </h3>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      After file copy based initial sync completes, if you run the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.count/#mongodb-method-db.collection.count">
       <code class="leafygreen-ui-1l06pbn">
        count()
       </code>
      </a>
      method without a query predicate, the
count of documents returned may be inaccurate.
     </p>
     <p class="leafygreen-ui-1kp3ins">
      A
      <code class="leafygreen-ui-1l06pbn">
       count
      </code>
      method without a query predicate looks like this:
      <code class="leafygreen-ui-1l06pbn">
       db.&lt;collection&gt;.count()
      </code>
      .
     </p>
     <p class="leafygreen-ui-1kp3ins">
      To learn more, see
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.count/#std-label-count-method-behavior-query-predicate">
       Inaccurate Counts Without Query Predicate
       <!-- -->
       .
      </a>
     </p>
    </div>
   </div>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Enable File Copy Based Initial Sync
     <a class="headerlink leafygreen-ui-1kepx47" href="#enable-file-copy-based-initial-sync" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="enable-file-copy-based-initial-sync">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     To enable file copy based initial sync, set the
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncMethod">
      <code class="leafygreen-ui-1l06pbn">
       initialSyncMethod
      </code>
     </a>
     parameter to
     <code class="leafygreen-ui-1l06pbn">
      fileCopyBased
     </code>
     on the
     <!-- -->
     destination member
     <!-- -->
     for the initial sync. This parameter can only be set
at startup.
    </p>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Behavior
     <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="behavior">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     File copy based initial sync replaces the
     <code class="leafygreen-ui-1l06pbn">
      local
     </code>
     database of the
     <!-- -->
     destination member
     <!-- -->
     with the
     <code class="leafygreen-ui-1l06pbn">
      local
     </code>
     database of the source member when
syncing.
    </p>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Limitations
     <a class="headerlink leafygreen-ui-1kepx47" href="#limitations" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="limitations">
      </div>
     </a>
    </h4>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       During a file copy based initial sync:
      </p>
      <ul class="leafygreen-ui-rioki0">
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         You cannot run backups on either the
         <!-- -->
         source member
         <!-- -->
         or the
         <!-- -->
         destination member
         <!-- -->
         .
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         You cannot write to the
         <code class="leafygreen-ui-1l06pbn">
          local
         </code>
         database on the
         <!-- -->
         destination member
         <!-- -->
         .
        </p>
       </li>
      </ul>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       You can only run an initial sync from one
       <!-- -->
       source member
       <!-- -->
       at a time.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       When using the encrypted storage engine, MongoDB uses the
       <!-- -->
       source member
       <!-- -->
       key to encrypt the destination.
      </p>
     </li>
    </ul>
   </section>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Initial Sync on NVMe Clusters
    <a class="headerlink leafygreen-ui-1kepx47" href="#initial-sync-on-nvme-clusters" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="initial-sync-on-nvme-clusters">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    You must perform an initial sync on clusters that use the local
Non-Volatile Memory Express (
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-NVMe">
     NVMe
    </a>
    ) SSD storage option, including
if you're using Atlas
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/cluster-autoscaling/#std-label-cluster-autoscaling" target="_self">
     <span>
      auto-scaling
     </span>
    </a>
    . Atlas
NVMe clusters auto-scale to the next higher tier when 90% of the storage
space is full. An initial sync takes longer to complete compared to
subsequent syncs, and reduces the performance of the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
     primary
    </a>
    from which the data is read.
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-init-sync-retry">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Fault Tolerance
    <a class="headerlink leafygreen-ui-1kepx47" href="#fault-tolerance" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="fault-tolerance">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    If a
    <!-- -->
    destination member
    <!-- -->
    performing initial sync encounters a persistent network
error during the sync process, the
    <!-- -->
    destination member
    <!-- -->
    restarts the initial sync
process from the beginning.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    A
    <!-- -->
    destination member
    <!-- -->
    performing initial sync can attempt to resume the sync process
if interrupted by a temporary network error, collection drop, or
collection rename.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    By default, the
    <!-- -->
    destination member
    <!-- -->
    tries to resume initial sync for 24 hours.
You can use the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncTransientErrorRetryPeriodSeconds">
     <code class="leafygreen-ui-1l06pbn">
      initialSyncTransientErrorRetryPeriodSeconds
     </code>
    </a>
    server parameter to control the amount of time the
    <!-- -->
    destination member
    <!-- -->
    attempts to
resume initial sync. If the
    <!-- -->
    destination member
    <!-- -->
    cannot successfully resume the
initial sync process during the configured time period, it selects a new
healthy
    <!-- -->
    source member
    <!-- -->
    from the replica set and restarts the initial
synchronization process from the beginning.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The secondary attempts to restart the initial sync up to
    <code class="leafygreen-ui-1l06pbn">
     10
    </code>
    times
before returning a fatal error.
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-initial-sync-source-selection">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Initial Sync Source Selection
    <a class="headerlink leafygreen-ui-1kepx47" href="#initial-sync-source-selection" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="initial-sync-source-selection">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Initial sync source selection depends on the value of the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    startup parameter
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
     <code class="leafygreen-ui-1l06pbn">
      initialSyncSourceReadPreference
     </code>
     :
    </a>
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      For
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
       <code class="leafygreen-ui-1l06pbn">
        initialSyncSourceReadPreference
       </code>
      </a>
      set to
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#mongodb-readmode-primary">
       <code class="leafygreen-ui-1l06pbn">
        primary
       </code>
      </a>
      (default if
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.chainingAllowed">
       <code class="leafygreen-ui-1l06pbn">
        chainingAllowed
       </code>
      </a>
      is disabled), select the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
       primary
      </a>
      as the
      <!-- -->
      source member
      <!-- -->
      . If the primary is unavailable or unreachable, log
an error and periodically check for primary availability.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      For
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
       <code class="leafygreen-ui-1l06pbn">
        initialSyncSourceReadPreference
       </code>
      </a>
      set to
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#mongodb-readmode-primaryPreferred">
       <code class="leafygreen-ui-1l06pbn">
        primaryPreferred
       </code>
      </a>
      (default for voting replica set
members), attempt to select the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
       primary
      </a>
      as the
      <!-- -->
      source member
      <!-- -->
      . If
the primary is unavailable or unreachable, perform sync
      <!-- -->
      source member
      <!-- -->
      selection from the remaining replica set members.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      For all other supported read modes, perform sync
      <!-- -->
      source member
      <!-- -->
      selection
from the
      <!-- -->
      destination members
      <!-- -->
      .
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    Members performing initial
    <!-- -->
    source member
    <!-- -->
    selection make two passes through
the list of all replica set members:
   </p>
   <div aria-hidden="true">
   </div>
   <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs">
    <div class="leafygreen-ui-jp7pox" id="tabs-13">
     <div aria-label="Tabs to describe usage of firstpass/second pass" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist">
      <button aria-controls="_wv9redkg5" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_qxlz8m4w8" name="" role="tab" tabindex="0">
       <div class="leafygreen-ui-1nxuzmg">
        First Pass
       </div>
      </button>
      <button aria-controls="_5ipbaxrx7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lmwxgmwsg" name="" role="tab" tabindex="-1">
       <div class="leafygreen-ui-1nxuzmg">
        Second Pass
       </div>
      </button>
     </div>
     <div class="leafygreen-ui-ov1ktg">
      <div class="leafygreen-ui-1sg2lsz">
      </div>
     </div>
    </div>
    <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels">
     <div>
      <div aria-labelledby="_thu6jzkz2" class="" id="_pbx9hziun" role="tabpanel">
       <div class="leafygreen-ui-1kdmo88">
        <p class="leafygreen-ui-1kp3ins">
         The member applies the following criteria to each replica
set member when making the first pass for selecting a
initial
         <!-- -->
         source member
         <!-- -->
         :
        </p>
        <ul class="leafygreen-ui-rioki0">
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be in the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.PRIMARY">
            <code class="leafygreen-ui-1l06pbn">
             PRIMARY
            </code>
           </a>
           or
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY">
            <code class="leafygreen-ui-1l06pbn">
             SECONDARY
            </code>
           </a>
           replication state.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be online and reachable.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
            <code class="leafygreen-ui-1l06pbn">
             initialSyncSourceReadPreference
            </code>
           </a>
           is
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#mongodb-readmode-secondary">
            <code class="leafygreen-ui-1l06pbn">
             secondary
            </code>
           </a>
           or
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#mongodb-readmode-secondaryPreferred">
            <code class="leafygreen-ui-1l06pbn">
             secondaryPreferred
            </code>
           </a>
           ,
the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary">
            secondary
            <!-- -->
            .
           </a>
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.hidden">
            <code class="leafygreen-ui-1l06pbn">
             visible
            </code>
            .
           </a>
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be within
           <code class="leafygreen-ui-1l06pbn">
            30
           </code>
           seconds of the newest
oplog entry on the primary.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.buildIndexes">
            <code class="leafygreen-ui-1l06pbn">
             builds indexes
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           build indexes.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes">
            <code class="leafygreen-ui-1l06pbn">
             votes
            </code>
           </a>
           in
replica set elections, the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           also vote.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member is
           <em>
            not
           </em>
           a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             delayed member
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           <em>
            must not
           </em>
           be delayed.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <em>
            is
           </em>
           a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             delayed member
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           must have a shorter
configured delay.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be faster than
the current best sync source.
          </p>
         </li>
        </ul>
        <p class="leafygreen-ui-1kp3ins">
         If no candidate
         <!-- -->
         source member
         <!-- -->
         remains after the first pass,
the member performs a second pass with relaxed criteria.
See
         <span class="guilabel css-h15tq0">
          Sync Source Selection (Second Pass)
         </span>
         .
        </p>
       </div>
      </div>
     </div>
     <div>
      <div aria-labelledby="_uz5fgtauy" class="leafygreen-ui-38lglc" id="_fn8wrm1ka" role="tabpanel">
       <div class="leafygreen-ui-1kdmo88">
        <p class="leafygreen-ui-1kp3ins">
         The member applies the following criteria to each replica
set member when making the second pass for selecting a
initial
         <!-- -->
         source member
         <!-- -->
         :
        </p>
        <ul class="leafygreen-ui-rioki0">
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be in the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.PRIMARY">
            <code class="leafygreen-ui-1l06pbn">
             PRIMARY
            </code>
           </a>
           or
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY">
            <code class="leafygreen-ui-1l06pbn">
             SECONDARY
            </code>
           </a>
           replication
state.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be online and reachable.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
            <code class="leafygreen-ui-1l06pbn">
             initialSyncSourceReadPreference
            </code>
           </a>
           is
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#mongodb-readmode-secondary">
            <code class="leafygreen-ui-1l06pbn">
             secondary
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary">
            secondary
            <!-- -->
            .
           </a>
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.buildIndexes">
            <code class="leafygreen-ui-1l06pbn">
             builds indexes
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           must
build indexes.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be faster than
the current best sync source.
          </p>
         </li>
        </ul>
       </div>
      </div>
     </div>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    If the
    <!-- -->
    destination member
    <!-- -->
    cannot select a
    <!-- -->
    source member
    <!-- -->
    after two passes, it
logs an error and waits
    <code class="leafygreen-ui-1l06pbn">
     1
    </code>
    second before restarting the selection
process. The secondary
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    can restart the initial
sync source selection process up to
    <code class="leafygreen-ui-1l06pbn">
     10
    </code>
    times before exiting with an
error.
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Oplog Window
    <a class="headerlink leafygreen-ui-1kepx47" href="#oplog-window" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="oplog-window">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog-window">
     oplog window
    </a>
    must be long enough so that a
    <!-- -->
    destination member
    <!-- -->
    can fetch
any new
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog">
     oplog
    </a>
    entries that occur between the start and end of
the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-initial-sync-logical" target="_self">
     <span>
      Logical Initial Sync Process
     </span>
    </a>
    .
If the window isn't long enough, there is a risk that some entries may
fall off the
    <code class="leafygreen-ui-1l06pbn">
     oplog
    </code>
    before the
    <!-- -->
    destination member
    <!-- -->
    can apply them.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    It is recommended that you size the
    <code class="leafygreen-ui-1l06pbn">
     oplog
    </code>
    for additional time to fetch any
new
    <code class="leafygreen-ui-1l06pbn">
     oplog
    </code>
    entries.  This allows for changes that may occur during initial
syncs.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    For more information, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-replica-set-oplog-sizing">
     Oplog Size
     <!-- -->
     .
    </a>
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-replication">
   </span>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Replication
   <a class="headerlink leafygreen-ui-1kepx47" href="#replication" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="replication">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Destination members
   <!-- -->
   replicate data continuously after the initial sync.
   <!-- -->
   Destination members
   <!-- -->
   copy the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-replica-set-oplog">
    oplog
   </a>
   from
the
   <!-- -->
   source member
   <!-- -->
   and apply these operations in an asynchronous
process.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   Destination members
   <!-- -->
   automatically change their
   <!-- -->
   source member
   <!-- -->
   as needed
based on changes in the ping time and state of other members'
replication. See
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-replication-sync-source-selection" target="_self">
    <span>
     Replication Sync Source Selection
    </span>
   </a>
   for more information on
   <!-- -->
   source member
   <!-- -->
   selection criteria.
  </p>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-streaming-replication">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Streaming Replication
    <a class="headerlink leafygreen-ui-1kepx47" href="#streaming-replication" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="streaming-replication">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Source members
    <!-- -->
    send a continuous stream
of
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-replica-set-oplog">
     oplog
    </a>
    entries to their
    <!-- -->
    destination members
    <!-- -->
    .
Streaming replication mitigates replication lag in high-load and
high-latency networks. It also:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Reduces staleness for reads from secondaries.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Reduces risk of losing write operations with
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-wc-w">
       w: 1
      </a>
      due to
primary failover.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Reduces latency on write operations with
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-">
       <code class="leafygreen-ui-1l06pbn">
        w: "majority"
       </code>
      </a>
      and
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-wc-w">
       w: &gt;1
      </a>
      (that is, any write concern that
requires waiting for replication).
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    Use the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.oplogFetcherUsesExhaust">
     <code class="leafygreen-ui-1l06pbn">
      oplogFetcherUsesExhaust
     </code>
    </a>
    startup parameter to disable
streaming replication and using the older replication behavior.
Set the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.oplogFetcherUsesExhaust">
     <code class="leafygreen-ui-1l06pbn">
      oplogFetcherUsesExhaust
     </code>
    </a>
    parameter to
    <code class="leafygreen-ui-1l06pbn">
     false
    </code>
    only if
there are any resource constraints on the
    <!-- -->
    source member
    <!-- -->
    or if you wish
to limit MongoDB's usage of network bandwidth for replication.
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-internals-multi-threaded-replication">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Multithreaded Replication
    <a class="headerlink leafygreen-ui-1kepx47" href="#multithreaded-replication" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="multithreaded-replication">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    MongoDB applies write operations in batches using multiple threads to
improve concurrency. MongoDB groups batches by document ID (
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/#std-label-storage-wiredtiger">
     WiredTiger
    </a>
    ) and simultaneously applies each group of
operations using a different thread. MongoDB always applies write
operations to a given document in their original write order.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    Read operations that
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#std-label-replica-set-read-preference">
     target secondaries
    </a>
    and are
configured with a
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern/#std-label-read-concern">
     read concern
    </a>
    level of
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern-local/#mongodb-readconcern-readconcern.-local-">
     <code class="leafygreen-ui-1l06pbn">
      "local"
     </code>
    </a>
    or
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern-majority/#mongodb-readconcern-readconcern.-majority-">
     <code class="leafygreen-ui-1l06pbn">
      "majority"
     </code>
    </a>
    read from
a
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/#std-label-storage-wiredtiger">
     WiredTiger
    </a>
    snapshot of the data if the read
takes place on a secondary where replication batches are being applied.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    Reading from a snapshot guarantees a consistent view of the
data, and allows the read to occur simultaneously with the ongoing
replication without the need for a lock. As a result, secondary reads
requiring these read concern levels no longer need to wait for
replication batches to be applied, and can be handled as they are
received.
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Flow Control
    <a class="headerlink leafygreen-ui-1kepx47" href="#flow-control" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="flow-control">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Administrators can limit the rate at which
the primary applies its writes with the goal of keeping the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.optimes.lastCommittedOpTime">
     <code class="leafygreen-ui-1l06pbn">
      majority
committed
     </code>
    </a>
    lag under
a configurable maximum value
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.flowControlTargetLagSeconds">
     <code class="leafygreen-ui-1l06pbn">
      flowControlTargetLagSeconds
     </code>
     .
    </a>
   </p>
   <p class="leafygreen-ui-1kp3ins">
    By default, flow control is
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.enableFlowControl">
     <code class="leafygreen-ui-1l06pbn">
      enabled
     </code>
     .
    </a>
   </p>
   <div class="leafygreen-ui-15mdk4" role="note">
    <h2 class="leafygreen-ui-6n7b7d">
     Note
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      For flow control to engage, the replica set/sharded cluster must
have:
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setFeatureCompatibilityVersion/#std-label-view-fcv">
       featureCompatibilityVersion (fCV)
      </a>
      of
      <code class="leafygreen-ui-1l06pbn">
       4.2
      </code>
      and read concern
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-replication.enableMajorityReadConcern">
       <code class="leafygreen-ui-1l06pbn">
        majority enabled
       </code>
      </a>
      . That is, enabled flow
control has no effect if fCV is not
      <code class="leafygreen-ui-1l06pbn">
       4.2
      </code>
      or if read concern
majority is disabled.
     </p>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    For more information, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/troubleshoot-replica-sets/#std-label-flow-control">
     Flow Control
     <!-- -->
     .
    </a>
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-replication-sync-source-selection">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Replication Sync Source Selection
    <a class="headerlink leafygreen-ui-1kepx47" href="#replication-sync-source-selection" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="replication-sync-source-selection">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Replication
    <!-- -->
    source member
    <!-- -->
    selection depends on the replica set
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.chainingAllowed">
     <code class="leafygreen-ui-1l06pbn">
      chaining
     </code>
    </a>
    setting:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      With chaining enabled (default), perform
      <!-- -->
      source member
      <!-- -->
      selection from
the
      <!-- -->
      destination members
      <!-- -->
      .
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      With chaining disabled, select the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
       primary
      </a>
      as the
      <!-- -->
      source member
      <!-- -->
      .
If the primary is unavailable or unreachable, log an error and
periodically check for primary availability.
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    Members performing replication
    <!-- -->
    source member
    <!-- -->
    selection make two passes
through the list of all replica set members:
   </p>
   <div aria-hidden="true">
   </div>
   <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs">
    <div class="leafygreen-ui-jp7pox" id="tabs-20">
     <div aria-label="Tabs to describe usage of firstpass/second pass" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist">
      <button aria-controls="_lrdl3noww" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_hs9c7ptbz" name="" role="tab" tabindex="0">
       <div class="leafygreen-ui-1nxuzmg">
        First Pass
       </div>
      </button>
      <button aria-controls="_nsfm2ygzw" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nyu4kv1az" name="" role="tab" tabindex="-1">
       <div class="leafygreen-ui-1nxuzmg">
        Second Pass
       </div>
      </button>
     </div>
     <div class="leafygreen-ui-ov1ktg">
      <div class="leafygreen-ui-1sg2lsz">
      </div>
     </div>
    </div>
    <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels">
     <div>
      <div aria-labelledby="_psukhrdtw" class="" id="_9aicogtqx" role="tabpanel">
       <div class="leafygreen-ui-1kdmo88">
        <p class="leafygreen-ui-1kp3ins">
         The member applies the following criteria to each replica
set member when making the first pass for selecting a
         <!-- -->
         source member
         <!-- -->
         :
        </p>
        <ul class="leafygreen-ui-rioki0">
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be in the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.PRIMARY">
            <code class="leafygreen-ui-1l06pbn">
             PRIMARY
            </code>
           </a>
           or
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY">
            <code class="leafygreen-ui-1l06pbn">
             SECONDARY
            </code>
           </a>
           replication state.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be online and reachable.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           have newer oplog entries than the member.
That is, the
           <!-- -->
           source member
           <!-- -->
           must be
           <em>
            ahead
           </em>
           of the member.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.hidden">
            <code class="leafygreen-ui-1l06pbn">
             visible
            </code>
            .
           </a>
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be within
           <code class="leafygreen-ui-1l06pbn">
            30
           </code>
           seconds of the newest
oplog entry on the primary.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.buildIndexes">
            <code class="leafygreen-ui-1l06pbn">
             builds indexes
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           build indexes.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes">
            <code class="leafygreen-ui-1l06pbn">
             votes
            </code>
           </a>
           in
replica set elections, the
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           also vote.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member is
           <em>
            not
           </em>
           a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             delayed member
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           <em>
            must not
           </em>
           be delayed.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <em>
            is
           </em>
           a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             delayed member
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           must have a shorter
configured delay.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be faster than the current best sync source.
          </p>
         </li>
        </ul>
        <p class="leafygreen-ui-1kp3ins">
         If no candidate
         <!-- -->
         source members
         <!-- -->
         remain after the first pass,
the member performs a second pass with relaxed criteria.
See the
         <span class="guilabel css-h15tq0">
          Sync Source Selection (Second Pass)
         </span>
         .
        </p>
       </div>
      </div>
     </div>
     <div>
      <div aria-labelledby="_7ybluv7ud" class="leafygreen-ui-38lglc" id="_jrojriskj" role="tabpanel">
       <div class="leafygreen-ui-1kdmo88">
        <p class="leafygreen-ui-1kp3ins">
         The member applies the following criteria to each replica
set member when making the second pass for selecting a
         <!-- -->
         source member
         <!-- -->
         :
        </p>
        <ul class="leafygreen-ui-rioki0">
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be in the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.PRIMARY">
            <code class="leafygreen-ui-1l06pbn">
             PRIMARY
            </code>
           </a>
           or
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY">
            <code class="leafygreen-ui-1l06pbn">
             SECONDARY
            </code>
           </a>
           replication
state.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be online and reachable.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           If the member
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.buildIndexes">
            <code class="leafygreen-ui-1l06pbn">
             builds indexes
            </code>
           </a>
           , the
           <!-- -->
           source member
           <!-- -->
           must
build indexes.
          </p>
         </li>
         <li class="leafygreen-ui-d7p7b6">
          <p class="leafygreen-ui-1kp3ins">
           The
           <!-- -->
           source member
           <!-- -->
           <em>
            must
           </em>
           be faster than the current best sync source.
          </p>
         </li>
        </ul>
       </div>
      </div>
     </div>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    If the member cannot select a sync source after two passes, it logs an
error and waits
    <code class="leafygreen-ui-1l06pbn">
     1
    </code>
    second before restarting the selection process.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The number of times a
    <!-- -->
    source member
    <!-- -->
    can be changed per hour is
configurable by setting the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.maxNumSyncSourceChangesPerHour">
     <code class="leafygreen-ui-1l06pbn">
      maxNumSyncSourceChangesPerHour
     </code>
    </a>
    parameter.
   </p>
   <div class="leafygreen-ui-15mdk4" role="note">
    <h2 class="leafygreen-ui-6n7b7d">
     Note
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      The startup parameter
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.initialSyncSourceReadPreference">
       <code class="leafygreen-ui-1l06pbn">
        initialSyncSourceReadPreference
       </code>
      </a>
      takes
precedence over the replica set's
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.chainingAllowed">
       <code class="leafygreen-ui-1l06pbn">
        settings.chainingAllowed
       </code>
      </a>
      setting
when selecting an initial sync
      <!-- -->
      source member
      <!-- -->
      . After a replica set member
successfully performs initial sync, it defers to the value of
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.chainingAllowed">
       <code class="leafygreen-ui-1l06pbn">
        chainingAllowed
       </code>
      </a>
      when selecting a
      <!-- -->
      source member
      <!-- -->
      .
     </p>
     <p class="leafygreen-ui-1kp3ins">
      See
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-initial-sync-source-selection" target="_self">
       <span>
        Initial Sync Source Selection
       </span>
      </a>
      for more
information on initial sync source selection.
     </p>
    </div>
   </div>
  </section>
 </section>
</section>
