<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Write Concern
  <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern" 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="write-concern">
   </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="#write-concern-specification" target="_self">
     <span>
      Write Concern Specification
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#implicit-default-write-concern" target="_self">
     <span>
      Implicit Default Write Concern
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#acknowledgment-behavior" target="_self">
     <span>
      Acknowledgment Behavior
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-information" target="_self">
     <span>
      Additional Information
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  Write concern describes the level of acknowledgment requested from
MongoDB for write operations to a standalone
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
   <code class="leafygreen-ui-1l06pbn">
    mongod
   </code>
  </a>
  ,
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication">
   replica sets
  </a>
  , or
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/#std-label-sharding-background">
   sharded clusters
  </a>
  . In sharded clusters,
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
   <code class="leafygreen-ui-1l06pbn">
    mongos
   </code>
  </a>
  instances will pass the write concern on to the shards.
 </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
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions">
     multi-document transactions
    </a>
    , you set
the write concern at the transaction level,
    <strong class="css-4dei7l">
     not at the individual
operation level
    </strong>
    . Do not explicitly set the write concern for
individual write operations in a transaction.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    If you specify a
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       "majority"
      </code>
     </span>
    </a>
    write concern for a
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions">
     multi-document transaction
    </a>
    and the
transaction fails to replicate to the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-calculating-majority-count" target="_self">
     <span>
      calculated majority
     </span>
    </a>
    of
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set">
     replica set
    </a>
    members, then the
transaction may not immediately roll back on replica set members.
The replica set will be
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-eventual-consistency">
     eventually consistent
    </a>
    . A transaction is always applied or rolled back on all
replica set members.
   </p>
  </div>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  Replica sets and sharded clusters support setting a global default write
concern. Operations which do not specify an explicit write concern inherit the
global default write concern settings. See
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern">
   <code class="leafygreen-ui-1l06pbn">
    setDefaultRWConcern
   </code>
  </a>
  for
more information.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  To learn more about setting the write concern for deployments
hosted in MongoDB Atlas, see
  <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/resilient-application/#write-concern" target="_self">
   <span>
    Build a Resilient Application with MongoDB Atlas
   </span>
  </a>
 </p>
 <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-specs">
 </span>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Write Concern Specification
   <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern-specification" 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="write-concern-specification">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Write concern can include the following fields:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ w: &lt;value&gt;, j: &lt;boolean&gt;, wtimeout: &lt;number&gt; }","programmingLanguage":"JavaScript"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-1q4bxgx" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">w</span>: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">j</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">wtimeout</span>: &lt;<!-- -->number<!-- -->&gt; <!-- -->}</td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     the
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
      <span>
       w
      </span>
     </a>
     option to request acknowledgment that the write
operation has propagated to a specified number of
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     instances or to
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     instances with specified tags.
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     the
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
      <span>
       j
      </span>
     </a>
     option to request acknowledgment that the write
operation has been written to the on-disk journal, and
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     the
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-wtimeout" target="_self">
      <span>
       wtimeout
      </span>
     </a>
     option to specify a time limit to
prevent write operations from blocking indefinitely.
    </p>
   </li>
  </ul>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-w">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    Option
    <a class="headerlink leafygreen-ui-1kepx47" href="#w-option" 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="w-option">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    option requests acknowledgment that the write operation has
propagated to a specified number of
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    instances or
to
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    instances with specified tags. If the write
concern is missing the
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    field, MongoDB sets the
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    option to the
default write concern.
   </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">
      If you use the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern">
       <code class="leafygreen-ui-1l06pbn">
        setDefaultRWConcern
       </code>
      </a>
      to set the default
write concern, you must specify a
      <code class="leafygreen-ui-1l06pbn">
       w
      </code>
      field value.
     </p>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    Using the
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    option, the following
    <code class="leafygreen-ui-1l06pbn">
     w: &lt;value&gt;
    </code>
    write concerns are
available:
   </p>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:25%"/>
      <col style="width:75%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Value
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Description
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <dl class="writeconcern">
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             "majority"
            </code>
            <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-writeconcern-writeconcern.-majority-" title="Permalink to this definition">
             <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="mongodb-writeconcern-writeconcern.-majority-">
             </div>
            </a>
           </dt>
           <dd>
           </dd>
          </dl>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <p class="leafygreen-ui-1kp3ins">
           Requests acknowledgment that the
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-calculating-majority-count" target="_self">
            <span>
             calculated majority
            </span>
           </a>
           of data-bearing voting members
have durably written the change to their local
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog">
            oplog
           </a>
           .
The members then asynchronously apply changes as they read them
from their local oplogs.
          </p>
          <div>
           <p>
            <em>
             Changed
             <!-- -->
             in version
             <!-- -->
             8.0
            </em>
            :
            <!-- -->
            <!-- -->
            MongoDB doesn't wait for the members to apply
the change before it acknowledges the write, as it did in previous
releases.
           </p>
          </div>
          <p class="leafygreen-ui-1kp3ins">
           The data-bearing voting members of a replica set are the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
            primary
           </a>
           member and any
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary">
            secondary
           </a>
           members with
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes">
            <code class="leafygreen-ui-1l06pbn">
             members[n].votes
            </code>
           </a>
           greater than
           <code class="leafygreen-ui-1l06pbn">
            0
           </code>
           .
          </p>
          <p class="leafygreen-ui-1kp3ins">
           For more information, see
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-concern-majority-reads" target="_self">
            <span>
             Reads after { w: "majority" } Writes
             <!-- -->
             .
            </span>
           </a>
          </p>
          <p class="leafygreen-ui-1kp3ins">
           <code class="leafygreen-ui-1l06pbn">
            { w: "majority" }
           </code>
           is the default write concern for
           <em>
            most
           </em>
           MongoDB
deployments. See
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-default-behavior" target="_self">
            <span>
             Implicit Default Write Concern
             <!-- -->
             .
            </span>
           </a>
          </p>
          <p class="leafygreen-ui-1kp3ins">
           For example, consider a replica set with 3 voting members,
Primary-Secondary-Secondary (P-S-S). For this replica set,
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-calculating-majority-count" target="_self">
            <span>
             calculated majority
            </span>
           </a>
           is two, and
the write must propagate to the oplogs of the primary and one secondary
to acknowledge the write concern to the client.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-hidden-member/#std-label-replica-set-hidden-members">
            Hidden
           </a>
           ,
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-delayed-member/#std-label-replica-set-delayed-members">
            delayed
           </a>
           ,
and
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/#std-label-replica-set-secondary-only-members">
            priority 0
           </a>
           members with
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes">
            <code class="leafygreen-ui-1l06pbn">
             members[n].votes
            </code>
           </a>
           greater than
           <code class="leafygreen-ui-1l06pbn">
            0
           </code>
           can acknowledge
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              "majority"
             </code>
            </span>
           </a>
           write operations.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           Delayed secondaries can return write acknowledgment no earlier
than the configured
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             secondaryDelaySecs
            </code>
            .
           </a>
          </p>
          <p class="leafygreen-ui-1kp3ins">
           After the write operation returns with a
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              w:
"majority"
             </code>
            </span>
           </a>
           acknowledgment to the client, the
client can read the result of that write with a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern-majority/#mongodb-readconcern-readconcern.-majority-">
            <code class="leafygreen-ui-1l06pbn">
             "majority"
            </code>
           </a>
           readConcern.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           If you specify a
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              "majority"
             </code>
            </span>
           </a>
           write concern for a
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions">
            multi-document transaction
           </a>
           and the
transaction fails to replicate to the
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-calculating-majority-count" target="_self">
            <span>
             calculated majority
            </span>
           </a>
           of
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set">
            replica set
           </a>
           members, then the
transaction may not immediately roll back on replica set members.
The replica set will be
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-eventual-consistency">
            eventually consistent
           </a>
           . A transaction is always applied or rolled back on all
replica set members.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           See
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-ack-behavior" target="_self">
            <span>
             Acknowledgment Behavior
            </span>
           </a>
           for when
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
           </a>
           instances
acknowledge the write.
          </p>
          <span class="leafygreen-ui-1qnjd6d" id="std-label-write-concern-lv-number">
          </span>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <dl class="writeconcern">
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             &lt;number&gt;
            </code>
            <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-writeconcern-writeconcern.-number-" title="Permalink to this definition">
             <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="mongodb-writeconcern-writeconcern.-number-">
             </div>
            </a>
           </dt>
           <dd>
           </dd>
          </dl>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <p class="leafygreen-ui-1kp3ins">
           Requests acknowledgment that the write operation has propagated
to the specified number of
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
           </a>
           instances. For
example:
          </p>
          <dl>
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             w: 1
            </code>
           </dt>
           <dd class="css-1ufxuu7">
            <p class="leafygreen-ui-1kp3ins">
             Requests acknowledgment that the write operation has
propagated to the standalone
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
              <code class="leafygreen-ui-1l06pbn">
               mongod
              </code>
             </a>
             or the primary
in a replica set. Data can be
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-rollbacks/#std-label-rollback-avoid">
              rolled back
             </a>
             if the primary steps down before the write operations have
replicated to any of the secondaries.
            </p>
            <p class="leafygreen-ui-1kp3ins">
             <strong class="css-4dei7l">
              WARNING:
             </strong>
             If write operations use
             <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-number-" target="_self">
              <span>
               <code class="leafygreen-ui-1l06pbn">
                { w: 1 }
               </code>
              </span>
             </a>
             write concern,
the rollback directory may exclude writes submitted after an
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog-hole">
              oplog hole
             </a>
             if the primary restarts before the write
operation completes.
            </p>
           </dd>
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             w: 0
            </code>
           </dt>
           <dd class="css-1ufxuu7">
            <p class="leafygreen-ui-1kp3ins">
             Requests no acknowledgment of the write operation. However,
             <code class="leafygreen-ui-1l06pbn">
              w:
0
             </code>
             may return information about socket exceptions and
networking errors to the application. Data can be
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-rollbacks/#std-label-rollback-avoid">
              rolled back
             </a>
             if the primary steps down
before the write operations have replicated to any of the
secondaries.
            </p>
            <p class="leafygreen-ui-1kp3ins">
             If you specify
             <code class="leafygreen-ui-1l06pbn">
              w: 0
             </code>
             but include
             <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
              <span>
               j: true
              </span>
             </a>
             , the
             <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
              <span>
               j: true
              </span>
             </a>
             prevails to request acknowledgment from
the standalone
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
              <code class="leafygreen-ui-1l06pbn">
               mongod
              </code>
             </a>
             or the primary of a replica
set.
            </p>
           </dd>
          </dl>
          <p class="leafygreen-ui-1kp3ins">
           <code class="leafygreen-ui-1l06pbn">
            w
           </code>
           greater than 1 requires acknowledgment from the primary
and as many data-bearing secondaries as needed to meet the
specified write concern. The secondaries do not need to be
voting members to meet the write concern threshold.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           For example, consider a 3-member replica set with a primary and 2
secondaries. Specifying
           <code class="leafygreen-ui-1l06pbn">
            w: 2
           </code>
           would require acknowledgment from the
primary and one of the secondaries. Specifying
           <code class="leafygreen-ui-1l06pbn">
            w: 3
           </code>
           would require
acknowledgment from the primary and both secondaries.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-hidden-member/#std-label-replica-set-hidden-members">
            Hidden
           </a>
           ,
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-delayed-member/#std-label-replica-set-delayed-members">
            delayed
           </a>
           ,
and
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/#std-label-replica-set-secondary-only-members">
            priority 0
           </a>
           members can acknowledge
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-number-" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              w: &lt;number&gt;
             </code>
            </span>
           </a>
           write operations.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           Delayed secondaries can return write acknowledgment no earlier
than the configured
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
            <code class="leafygreen-ui-1l06pbn">
             secondaryDelaySecs
            </code>
            .
           </a>
          </p>
          <p class="leafygreen-ui-1kp3ins">
           See
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-ack-behavior" target="_self">
            <span>
             Acknowledgment Behavior
            </span>
           </a>
           for when
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
           </a>
           instances
acknowledge the write.
          </p>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <dl class="writeconcern">
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             &lt;custom write concern name&gt;
            </code>
            <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-writeconcern-writeconcern.-custom-write-concern-name-" title="Permalink to this definition">
             <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="mongodb-writeconcern-writeconcern.-custom-write-concern-name-">
             </div>
            </a>
           </dt>
           <dd>
           </dd>
          </dl>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <p class="leafygreen-ui-1kp3ins">
           Requests acknowledgment that the write operations have
propagated to
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.tags">
            <code class="leafygreen-ui-1l06pbn">
             tagged
            </code>
           </a>
           members that
satisfy the custom write concern defined in
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.getLastErrorModes">
            <code class="leafygreen-ui-1l06pbn">
             settings.getLastErrorModes
            </code>
           </a>
           . For an example, see
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-replica-set-tag-sets/#std-label-configure-custom-write-concern">
            Custom Multi-Datacenter Write Concerns
            <!-- -->
            .
           </a>
          </p>
          <p class="leafygreen-ui-1kp3ins">
           Data can be
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-rollbacks/#std-label-rollback-avoid">
            rolled back
           </a>
           if the custom
write concern only requires acknowledgment from the primary and
the primary steps down before the write operations have
replicated to any of the secondaries.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           See
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-ack-behavior" target="_self">
            <span>
             Acknowledgment Behavior
            </span>
           </a>
           for when
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
           </a>
           instances acknowledge the write.
          </p>
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <div class="leafygreen-ui-13vw3ie" role="note">
    <h2 class="leafygreen-ui-1fn4p2b">
     Tip
    </h2>
    <h3 class="leafygreen-ui-144d5kf">
     <strong>
      See also:
     </strong>
    </h3>
    <div class="leafygreen-ui-9mycqc">
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-defaults/#std-label-default-mongodb-read-write-concerns">
         Default MongoDB Read Concerns/Write Concerns
        </a>
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-set-protocol-versions/#std-label-replica-set-protocol-version">
         Self-Managed Replica Set Protocol Version
        </a>
       </p>
      </li>
     </ul>
    </div>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-j">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     j
    </code>
    Option
    <a class="headerlink leafygreen-ui-1kepx47" href="#j-option" 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="j-option">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The
    <code class="leafygreen-ui-1l06pbn">
     j
    </code>
    option requests acknowledgment from MongoDB that
the write operation has been written to the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/journaling/#std-label-journaling-internals">
     on-disk journal
     <!-- -->
     .
    </a>
   </p>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:20%"/>
      <col style="width:80%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
     </thead>
     <tbody>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <dl class="writeconcern">
           <dt>
            <code class="leafygreen-ui-1l06pbn">
             j
            </code>
            <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-writeconcern-writeconcern.j" title="Permalink to this definition">
             <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="mongodb-writeconcern-writeconcern.j">
             </div>
            </a>
           </dt>
           <dd>
           </dd>
          </dl>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <p class="leafygreen-ui-1kp3ins">
           If
           <code class="leafygreen-ui-1l06pbn">
            j: true
           </code>
           , requests acknowledgment that the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
           </a>
           instances, as specified in the
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
            <span>
             w:
&lt;value&gt;
            </span>
           </a>
           , have written to the on-disk journal.
           <code class="leafygreen-ui-1l06pbn">
            j:
true
           </code>
           does not by itself guarantee that the write will not be
rolled back due to replica set primary failover.
          </p>
          <p class="leafygreen-ui-1kp3ins">
           With
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.j" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              j: true
             </code>
            </span>
           </a>
           , MongoDB returns only after the
requested number of members, including the primary, have written to the
journal. Previously
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.j" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              j: true
             </code>
            </span>
           </a>
           write concern in a
replica set only requires the
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary">
            primary
           </a>
           to write to the journal,
regardless of the
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
            <span>
             w: &lt;value&gt;
            </span>
           </a>
           write concern.
          </p>
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <div class="leafygreen-ui-15mdk4" role="note">
    <h2 class="leafygreen-ui-6n7b7d">
     Note
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        Specifying a write concern that includes
        <code class="leafygreen-ui-1l06pbn">
         j: true
        </code>
        to a
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
         <code class="leafygreen-ui-1l06pbn">
          mongod
         </code>
        </a>
        instance that is running without journaling
produces an error.
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        If journaling is enabled,
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           w:
"majority"
          </code>
         </span>
        </a>
        may imply
        <code class="leafygreen-ui-1l06pbn">
         j: true
        </code>
        . The
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.writeConcernMajorityJournalDefault">
         <code class="leafygreen-ui-1l06pbn">
          writeConcernMajorityJournalDefault
         </code>
        </a>
        replica set
configuration setting determines the behavior. See
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-ack-behavior" target="_self">
         <span>
          Acknowledgment Behavior
         </span>
        </a>
        for details.
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        A write concern that includes or implies
        <code class="leafygreen-ui-1l06pbn">
         j: true
        </code>
        causes an
immediate journal synchronization. See
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/journaling/#std-label-journal-process">
         Journaling Process
         <!-- -->
         .
        </a>
       </p>
      </li>
     </ul>
    </div>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-wtimeout">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#wtimeout" 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="wtimeout">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    This option specifies a time limit, in milliseconds, for the write
concern.
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    is only applicable for
    <code class="leafygreen-ui-1l06pbn">
     w
    </code>
    values greater than
    <code class="leafygreen-ui-1l06pbn">
     1
    </code>
    .
   </p>
   <p class="leafygreen-ui-1kp3ins">
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    causes write operations to return with an error
after the specified limit, even if the required write concern will
eventually succeed. When these write operations return,
MongoDB
    <strong>
     does not
    </strong>
    undo successful data modifications performed
before the write concern exceeded the
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    time limit.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    If you do not specify the
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    option and the level of write
concern is unachievable, the write operation will block indefinitely.
Specifying a
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    value of
    <code class="leafygreen-ui-1l06pbn">
     0
    </code>
    is equivalent to a write
concern without the
    <code class="leafygreen-ui-1l06pbn">
     wtimeout
    </code>
    option.
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-default-behavior">
   </span>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Implicit Default Write Concern
   <a class="headerlink leafygreen-ui-1kepx47" href="#implicit-default-write-concern" 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="implicit-default-write-concern">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Starting in MongoDB 5.0, the implicit default
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-concern" target="_self">
    <span>
     write concern
    </span>
   </a>
   is
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      w: majority
     </code>
    </span>
   </a>
   . However, special
considerations are made for deployments containing
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-arbiter/#std-label-replica-set-arbiter-configuration">
    arbiters
    <!-- -->
    :
   </a>
  </p>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     The voting majority of a replica set is 1 plus half the number of
voting members, rounded down. If the number of data-bearing voting
members is not greater than the voting majority, the default write
concern is
     <code class="leafygreen-ui-1l06pbn">
      { w: 1 }
     </code>
     .
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     In all other scenarios, the default write concern is
     <code class="leafygreen-ui-1l06pbn">
      { w:
"majority" }
     </code>
     .
    </p>
   </li>
  </ul>
  <p class="leafygreen-ui-1kp3ins">
   Specifically, MongoDB uses the following formula to determine the
default write concern:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"if [ (#arbiters &gt; 0) AND (#non-arbiters &lt;= majority(#voting-nodes)) ]\n    defaultWriteConcern = { w: 1 }\nelse\n    defaultWriteConcern = { w: \"majority\" }"}
  </script>
  <div class="css-1lju8ps">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-tyg50d">
     <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">if [ (#arbiters &gt; 0) AND (#non-arbiters &lt;= majority(#voting-nodes)) ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    defaultWriteConcern = { w: 1 }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">else</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    defaultWriteConcern = { w: "majority" }</td></tr></tbody></table></code></pre>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   For example, consider the following deployments and their respective
default write concerns:
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Non-Arbiters
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Arbiters
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Voting Nodes
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Majority of Voting Nodes
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Implicit Default Write Concern
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         1
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         3
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          { w: 1 }
         </code>
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         4
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         1
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         5
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         3
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          { w: "majority" }
         </code>
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     In the first example:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       There are 2 non-arbiters and 1 arbiter for a total of 3 voting
nodes.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The majority of voting nodes (1 plus half of 3, rounded
down) is 2.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The number of non-arbiters (2) is equal to
the majority of voting nodes (2), resulting in an implicit write
concern of
       <code class="leafygreen-ui-1l06pbn">
        { w: 1 }
       </code>
       .
      </p>
     </li>
    </ul>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     In the second example:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       There are 4 non-arbiters and 1 arbiter for a total of 5
voting nodes.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The majority of voting nodes (1 plus half of 5, rounded
down) is 3.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The number of non-arbiters (4) is greater than the majority
of voting nodes (3), resulting in an implicit write concern of
       <code class="leafygreen-ui-1l06pbn">
        { w: "majority" }
       </code>
       .
      </p>
     </li>
    </ul>
   </li>
  </ul>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-ack-behavior">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Acknowledgment Behavior
   <a class="headerlink leafygreen-ui-1kepx47" href="#acknowledgment-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="acknowledgment-behavior">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
    <span>
     w
    </span>
   </a>
   option and the
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
    <span>
     j
    </span>
   </a>
   option determine
when
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   instances acknowledge write operations.
  </p>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Standalone
    <a class="headerlink leafygreen-ui-1kepx47" href="#standalone" 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="standalone">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    A standalone
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    acknowledges a write operation either
after applying the write in memory or after writing to the on-disk
journal. The following table lists the acknowledgment behavior for a
standalone and the relevant write concerns:
   </p>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:35%"/>
      <col style="width:40%"/>
      <col style="width:25%"/>
      <col style="width:20%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           j
          </code>
          is unspecified
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           j:true
          </code>
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           j:false
          </code>
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           w: 1
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          In memory
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          On-disk journal
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          In memory
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           w: "majority"
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          On-disk journal
          <em>
           if running with journaling
          </em>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          On-disk journal
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          In memory
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <div class="leafygreen-ui-15mdk4" role="note">
    <h2 class="leafygreen-ui-6n7b7d">
     Note
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      With
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.writeConcernMajorityJournalDefault">
       <code class="leafygreen-ui-1l06pbn">
        writeConcernMajorityJournalDefault
       </code>
      </a>
      set to
      <code class="leafygreen-ui-1l06pbn">
       false
      </code>
      ,
MongoDB does not wait for
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         w: "majority"
        </code>
       </span>
      </a>
      writes to be written to the on-disk journal before acknowledging the
writes. As such,
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      write operations could
possibly roll back in the event of a transient loss (e.g. crash and
restart) of a majority of nodes in a given replica set.
     </p>
    </div>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-replica-ack-behavior">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Replica Sets
    <a class="headerlink leafygreen-ui-1kepx47" href="#replica-sets" 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-sets">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The value specified to
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
     <span>
      w
     </span>
    </a>
    determines the number
of replica set members that must acknowledge the write before returning
success. For each eligible replica set member, the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
     <span>
      j
     </span>
    </a>
    option determines whether the member acknowledges writes after applying
the write operation in memory or after writing to the on-disk journal.
   </p>
   <dl>
    <dt>
     <code class="leafygreen-ui-1l06pbn">
      w: "majority"
     </code>
    </dt>
    <dd class="css-1ufxuu7">
     <p class="leafygreen-ui-1kp3ins">
      Any data-bearing voting member of the replica set can contribute
to write acknowledgment of
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      write
operations.
     </p>
     <p class="leafygreen-ui-1kp3ins">
      The following table lists when the member can acknowledge
the write based on the
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
       <span>
        j
       </span>
      </a>
      value:
     </p>
     <div class="leafygreen-ui-skkc39" tabindex="0">
      <table class="leafygreen-ui-hr8lsv">
       <colgroup>
        <col style="width:30%"/>
        <col style="width:70%"/>
       </colgroup>
       <thead class="leafygreen-ui-a9ho40">
       </thead>
       <tbody>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j
            </code>
            is unspecified
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <p class="leafygreen-ui-1kp3ins">
             Acknowledgment depends on the value of
             <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.writeConcernMajorityJournalDefault">
              <code class="leafygreen-ui-1l06pbn">
               writeConcernMajorityJournalDefault
              </code>
              :
             </a>
            </p>
            <ul class="leafygreen-ui-rioki0">
             <li class="leafygreen-ui-d7p7b6">
              <p class="leafygreen-ui-1kp3ins">
               If
               <code class="leafygreen-ui-1l06pbn">
                true
               </code>
               , acknowledgment requires writing operation to
on-disk journal (
               <code class="leafygreen-ui-1l06pbn">
                j: true
               </code>
               ).
              </p>
              <p class="leafygreen-ui-1kp3ins">
               <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.writeConcernMajorityJournalDefault">
                <code class="leafygreen-ui-1l06pbn">
                 writeConcernMajorityJournalDefault
                </code>
               </a>
               defaults to
               <code class="leafygreen-ui-1l06pbn">
                true
               </code>
              </p>
             </li>
             <li class="leafygreen-ui-d7p7b6">
              <p class="leafygreen-ui-1kp3ins">
               If
               <code class="leafygreen-ui-1l06pbn">
                false
               </code>
               , acknowledgment requires writing operation in
memory (
               <code class="leafygreen-ui-1l06pbn">
                j: false
               </code>
               ).
              </p>
             </li>
            </ul>
           </div>
          </div>
         </td>
        </tr>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j: true
            </code>
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            Acknowledgment requires writing operation to on-disk journal.
           </div>
          </div>
         </td>
        </tr>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j: false
            </code>
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <p class="leafygreen-ui-1kp3ins">
             Acknowledgment requires writing operation in memory.
            </p>
            <p class="leafygreen-ui-1kp3ins">
             Typically, if
             <code class="leafygreen-ui-1l06pbn">
              j: false
             </code>
             is set, writing the operation to the
on-disk journal isn't required. However, if
             <code class="leafygreen-ui-1l06pbn">
              writeConcernMajorityJournalDefault: true
             </code>
             is set, writing
the operation to the journal is required even if
             <code class="leafygreen-ui-1l06pbn">
              j: false
             </code>
             is set.
            </p>
            <p class="leafygreen-ui-1kp3ins">
             If
             <code class="leafygreen-ui-1l06pbn">
              j: false
             </code>
             and
             <code class="leafygreen-ui-1l06pbn">
              writeConcernMajorityJournalDefault:
true
             </code>
             are set, the write operations are written to the journal
asynchronously.
            </p>
            <ul class="leafygreen-ui-rioki0">
             <li class="leafygreen-ui-d7p7b6">
              <p class="leafygreen-ui-1kp3ins">
               Writes that have
               <code class="leafygreen-ui-1l06pbn">
                w: majority
               </code>
               set aren't acknowledged as
complete until the journal is flushed to disk.
              </p>
             </li>
             <li class="leafygreen-ui-d7p7b6">
              <p class="leafygreen-ui-1kp3ins">
               <code class="leafygreen-ui-1l06pbn">
                w: majority
               </code>
               writes wait for the
               <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 snapshot to complete, regardless of the
               <code class="leafygreen-ui-1l06pbn">
                j
               </code>
               setting.
This is because if
               <code class="leafygreen-ui-1l06pbn">
                writeConcernMajorityJournalDefault:
true
               </code>
               is set, the majority read snapshot is based on the
majority of journaled writes.
              </p>
             </li>
             <li class="leafygreen-ui-d7p7b6">
              <p class="leafygreen-ui-1kp3ins">
               After the write operation returns with a
               <code class="leafygreen-ui-1l06pbn">
                w: majority
               </code>
               acknowledgment to the client application, the application can
read the result of the write if the
               <code class="leafygreen-ui-1l06pbn">
                majority
               </code>
               read
concern is set.
              </p>
             </li>
            </ul>
           </div>
          </div>
         </td>
        </tr>
       </tbody>
      </table>
     </div>
     <p class="leafygreen-ui-1kp3ins">
      For behavior details, see
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-majority-behavior" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         w: "majority"
        </code>
        Behavior
        <!-- -->
        .
       </span>
      </a>
     </p>
    </dd>
    <dt>
     <code class="leafygreen-ui-1l06pbn">
      w: &lt;number&gt;
     </code>
    </dt>
    <dd class="css-1ufxuu7">
     <p class="leafygreen-ui-1kp3ins">
      Any data-bearing member of the replica set can contribute
to write acknowledgment of
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-w" target="_self">
       <span>
        w: &lt;number&gt;
       </span>
      </a>
      write
operations.
     </p>
     <p class="leafygreen-ui-1kp3ins">
      The following table lists when the member can acknowledge
the write based on the
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wc-j" target="_self">
       <span>
        j
       </span>
      </a>
      value:
     </p>
     <div class="leafygreen-ui-skkc39" tabindex="0">
      <table class="leafygreen-ui-hr8lsv">
       <colgroup>
        <col style="width:30%"/>
        <col style="width:70%"/>
       </colgroup>
       <thead class="leafygreen-ui-a9ho40">
       </thead>
       <tbody>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j
            </code>
            is unspecified
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            Acknowledgment requires writing operation in memory
(
            <code class="leafygreen-ui-1l06pbn">
             j: false
            </code>
            ).
           </div>
          </div>
         </td>
        </tr>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j: true
            </code>
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            Acknowledgment requires writing operation to on-disk journal.
           </div>
          </div>
         </td>
        </tr>
        <tr class="">
         <td class="leafygreen-ui-xejatx" role="rowheader">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            <code class="leafygreen-ui-1l06pbn">
             j: false
            </code>
           </div>
          </div>
         </td>
         <td class="leafygreen-ui-1drjk7h">
          <div class="leafygreen-ui-1n4j8xf">
           <div>
            Acknowledgment requires writing operation in memory.
           </div>
          </div>
         </td>
        </tr>
       </tbody>
      </table>
     </div>
    </dd>
   </dl>
   <div class="leafygreen-ui-15mdk4" role="note">
    <h2 class="leafygreen-ui-6n7b7d">
     Note
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-hidden-member/#std-label-replica-set-hidden-members">
       Hidden
      </a>
      ,
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-delayed-member/#std-label-replica-set-delayed-members">
       delayed
      </a>
      ,
and
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/#std-label-replica-set-secondary-only-members">
       priority 0
      </a>
      members can acknowledge
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-number-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         w: &lt;number&gt;
        </code>
       </span>
      </a>
      write operations.
     </p>
     <p class="leafygreen-ui-1kp3ins">
      Delayed secondaries can return write acknowledgment no earlier
than the configured
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
       <code class="leafygreen-ui-1l06pbn">
        secondaryDelaySecs
       </code>
       .
      </a>
     </p>
    </div>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-write-concern-majority-reads">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Reads after { w: "majority" } Writes
    <a class="headerlink leafygreen-ui-1kepx47" href="#reads-after---w---majority----writes" 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="reads-after---w---majority----writes">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Starting in MongoDB 8.0,
    <code class="leafygreen-ui-1l06pbn">
     { w: "majority" }
    </code>
    writes return an acknowledgment
after a majority of data-bearing members durably write the oplog entry. The members
then asynchronously apply the changes as they read them from their local oplogs.
In earlier releases, MongoDB waited until after the members applied the write to
return the acknowledgment.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    Queries on secondaries immediately after a
    <code class="leafygreen-ui-1l06pbn">
     { w: "majority" }
    </code>
    write
returns an acknowledgment may read from the collection before the secondary
applies changes from the write.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    If your application reads from secondaries and requires immediate access
to changes made in
    <code class="leafygreen-ui-1l06pbn">
     { w: "majority" }
    </code>
    writes, run these operations in
a
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-isolation-consistency-recency/#std-label-causal-consistency">
     causally consistent
    </a>
    session.
   </p>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Additional Information
   <a class="headerlink leafygreen-ui-1kepx47" href="#additional-information" 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="additional-information">
    </div>
   </a>
  </h2>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Causally Consistent Sessions and Write Concerns
    <a class="headerlink leafygreen-ui-1kepx47" href="#causally-consistent-sessions-and-write-concerns" 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="causally-consistent-sessions-and-write-concerns">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    With
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-isolation-consistency-recency/#std-label-sessions">
     causally consistent client sessions
    </a>
    , the
client sessions only guarantee causal consistency if:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      the associated read operations use
      <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
concern, and
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      the associated write operations use
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      write concern.
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    For details, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-isolation-consistency-recency/#std-label-causal-consistency">
     Causal Consistency
     <!-- -->
     .
    </a>
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wc-majority-behavior">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     w: "majority"
    </code>
    Behavior
    <a class="headerlink leafygreen-ui-1kepx47" href="#w---majority--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="w---majority--behavior">
     </div>
    </a>
   </h3>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      With
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.writeConcernMajorityJournalDefault">
       <code class="leafygreen-ui-1l06pbn">
        writeConcernMajorityJournalDefault
       </code>
      </a>
      set to
      <code class="leafygreen-ui-1l06pbn">
       false
      </code>
      ,
MongoDB does not wait for
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         w: "majority"
        </code>
       </span>
      </a>
      writes to be written to the on-disk journal before acknowledging the
writes. As such,
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      write operations could
possibly roll back in the event of a transient loss (e.g. crash and
restart) of a majority of nodes in a given replica set.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-hidden-member/#std-label-replica-set-hidden-members">
       Hidden
      </a>
      ,
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-delayed-member/#std-label-replica-set-delayed-members">
       delayed
      </a>
      ,
and
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/#std-label-replica-set-secondary-only-members">
       priority 0
      </a>
      members with
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes">
       <code class="leafygreen-ui-1l06pbn">
        members[n].votes
       </code>
      </a>
      greater than
      <code class="leafygreen-ui-1l06pbn">
       0
      </code>
      can acknowledge
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      write operations.
     </p>
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        Delayed secondaries can return write acknowledgment no earlier
than the configured
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs">
         <code class="leafygreen-ui-1l06pbn">
          secondaryDelaySecs
         </code>
         .
        </a>
       </p>
      </li>
     </ul>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Starting in MongoDB 5.0, replica set members in the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.STARTUP2">
       <code class="leafygreen-ui-1l06pbn">
        STARTUP2
       </code>
      </a>
      state do not participate in write majorities.
     </p>
    </li>
   </ul>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Write Concern not Supported on
    <code class="leafygreen-ui-1l06pbn">
     local
    </code>
    Database
    <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern-not-supported-on-local-database" 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="write-concern-not-supported-on-local-database">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/local-database/#std-label-replica-set-local-database">
     local database
    </a>
    does not support
write concerns. MongoDB silently ignores any configured write
concern for an operation on a collection in the local database.
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-calculating-majority-count">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Calculating Majority for Write Concern
    <a class="headerlink leafygreen-ui-1kepx47" href="#calculating-majority-for-write-concern" 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="calculating-majority-for-write-concern">
     </div>
    </a>
   </h3>
   <div class="leafygreen-ui-13vw3ie" role="note">
    <h2 class="leafygreen-ui-1fn4p2b">
     Tip
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      The
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.status/#mongodb-method-rs.status">
       <code class="leafygreen-ui-1l06pbn">
        rs.status()
       </code>
      </a>
      returns the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.writeMajorityCount">
       <code class="leafygreen-ui-1l06pbn">
        writeMajorityCount
       </code>
      </a>
      field which contains
the calculated majority number.
     </p>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    The majority for write concern
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       "majority"
      </code>
     </span>
    </a>
    is calculated
as the smaller of the following values:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      the majority of
      <em>
       all
      </em>
      voting members (including arbiters) vs.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      the number of all
      <strong>
       data-bearing
      </strong>
      voting members.
     </p>
    </li>
   </ul>
   <div class="leafygreen-ui-1sjx7ru" role="note">
    <h2 class="leafygreen-ui-29m78u">
     Warning
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      In cases where the calculated majority number is equal to the number
of all
      <strong>
       data-bearing
      </strong>
      voting members (such as with a 3-member
Primary-Secondary-Arbiter deployment), write concern
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         "majority"
        </code>
       </span>
      </a>
      may time out or never be acknowledged if
a data bearing voting member is down or unreachable. If possible,
use a data-bearing voting member instead of an arbiter.
     </p>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    For example, consider:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      A replica set with 3 voting members, Primary-Secondary-Secondary
(P-S-S):
     </p>
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        The majority of all voting members is 2.
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        The number of all data-bearing voting members is 3.
       </p>
      </li>
     </ul>
     <div class="line-block">
      <div class="line">
       The calculated majority is 2, the minimum of 2 and 3. The write
must propagate to the primary and one of the secondaries to
acknowledge the write concern
       <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
        <span>
         <code class="leafygreen-ui-1l06pbn">
          "majority"
         </code>
        </span>
       </a>
       to the
client.
      </div>
     </div>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      A replica set with 3 voting members, Primary-Secondary-Arbiter (P-S-A)
     </p>
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        The majority of all voting members is 2.
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        The number of all data-bearing voting members is 2.
       </p>
      </li>
     </ul>
     <div class="line-block">
      <div class="line">
       The calculated majority is 2, the minimum of 2 and 2. Since the
write can only be applied to data-bearing members, the write must
propagate to the primary and the secondary to acknowledge the write
concern
       <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
        <span>
         <code class="leafygreen-ui-1l06pbn">
          "majority"
         </code>
        </span>
       </a>
       to the client.
      </div>
     </div>
     <div class="leafygreen-ui-13vw3ie" role="note">
      <h2 class="leafygreen-ui-1fn4p2b">
       Tip
      </h2>
      <div class="leafygreen-ui-9mycqc">
       <p class="leafygreen-ui-1kp3ins">
        Avoid using a
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           "majority"
          </code>
         </span>
        </a>
        write concern with a
(P-S-A) or other topologies that require all data-bearing voting
members to be available to acknowledge the writes. Customers who
want the durability guarantees of using a
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-writeconcern-writeconcern.-majority-" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           "majority"
          </code>
         </span>
        </a>
        write concern should instead deploy a
topology that does not require all data bearing voting members to be
available (e.g. P-S-S).
       </p>
      </div>
     </div>
    </li>
   </ul>
   <div class="leafygreen-ui-1sjx7ru" role="note">
    <h2 class="leafygreen-ui-29m78u">
     Warning
    </h2>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      Avoid deploying more than one
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-arbiter">
       arbiter
      </a>
      in a
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set">
       replica set
      </a>
      . See
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-arbiter/#std-label-rollbacks-multi-arbiters">
       Concerns with Multiple Arbiters
       <!-- -->
       .
      </a>
     </p>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    To add an arbiter to an existing replica set:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Typically, if there are two or fewer data-bearing members in the
replica set, you might need to first set the
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#std-label-set_global_default_write_concern">
       cluster wide write
concern
      </a>
      for the replica set.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      See
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#std-label-set_global_default_write_concern">
       cluster wide write concern
      </a>
      for more information on why you
might need to set the cluster wide write concern.
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    You do not need to change the cluster wide write concern before starting
a new replica set with an arbiter.
   </p>
   <div class="leafygreen-ui-13vw3ie" role="note">
    <h2 class="leafygreen-ui-1fn4p2b">
     Tip
    </h2>
    <h3 class="leafygreen-ui-144d5kf">
     <strong>
      See also:
     </strong>
    </h3>
    <div class="leafygreen-ui-9mycqc">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-defaults/#std-label-default-wc-formula">
       Default write concern formula
      </a>
     </p>
    </div>
   </div>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Write Concern Provenance
    <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern-provenance" 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="write-concern-provenance">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    MongoDB tracks write concern
    <code class="leafygreen-ui-1l06pbn">
     provenance
    </code>
    , which indicates the source of a
particular write concern. You may see
    <code class="leafygreen-ui-1l06pbn">
     provenance
    </code>
    shown in the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/serverStatus/#mongodb-serverstatus-serverstatus.metrics.getLastError">
     <code class="leafygreen-ui-1l06pbn">
      getLastError
     </code>
    </a>
    metrics, write
concern error objects, and MongoDB logs.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The following table shows the possible write concern
    <code class="leafygreen-ui-1l06pbn">
     provenance
    </code>
    values and their significance:
   </p>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:20%"/>
      <col style="width:40%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Provenance
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Description
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           clientSupplied
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The write concern was specified in the application.
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           customDefault
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The write concern originated from a custom defined
default value. See
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern">
           <code class="leafygreen-ui-1l06pbn">
            setDefaultRWConcern
           </code>
           .
          </a>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           getLastErrorDefaults
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The write concern originated from the replica set's
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.getLastErrorDefaults">
           <code class="leafygreen-ui-1l06pbn">
            settings.getLastErrorDefaults
           </code>
          </a>
          field.
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           implicitDefault
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The write concern originated from the server in absence
of all other write concern specifications.
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-write-concern-contrasted-with-commit-quorum">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Write Concern Contrasted with Commit Quorum
    <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern-contrasted-with-commit-quorum" 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="write-concern-contrasted-with-commit-quorum">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    There are important differences between
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/createIndexes/#std-label-createIndexes-cmd-commitQuorum">
     commit quorums
    </a>
    and
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-concern" target="_self">
     <span>
      write concerns
      <!-- -->
      :
     </span>
    </a>
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Index builds use commit quorums.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Write operations use write concerns.
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    Each data-bearing node in a cluster is a voting member.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The commit quorum specifies how many data-bearing voting members, or
which voting members, including the primary, must be prepared to commit
a
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-creation/#std-label-index-operations-simultaneous-build">
     simultaneous index build
    </a>
    before the primary will execute the commit.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The write concern is the level of acknowledgment that the write has
propagated to the specified number of instances.
   </p>
   <div>
    <p>
     <em>
      Changed
      <!-- -->
      in version
      <!-- -->
      8.0
     </em>
     :
     <!-- -->
     <!-- -->
     The commit quorum specifies how many
nodes must be ready to finish the index build before the
primary commits the index build. In contrast, when the
primary has committed the index build, the write concern
specifies how many nodes must replicate the index build oplog
entry before the command returns success.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     In previous releases, when the primary committed the index
build, the write concern specified how many nodes must finish
the index build before the command returned success.
    </p>
   </div>
  </section>
 </section>
</section>
