@@ -22,19 +22,6 @@ MongoDB for write operations to a standalone :program:`mongod` or to
2222sharded clusters, :program:`mongos` instances will pass the write
2323concern on to the shards.
2424
25- .. versionchanged:: 3.2
26-
27- For replica sets using :rsconf:`protocolVersion: 1
28- <protocolVersion>` **and** running with the :term:`journal` enabled:
29-
30- - :writeconcern:`w: "majority" <"majority">` implies :ref:`j: true
31- <wc-j>`.
32-
33- - :term:`Secondary members <secondary>` acknowledge replicated write
34- operations after the secondary members have written to their
35- respective on-disk journals, regardless of the :ref:`j <wc-j>`
36- option used for the write on the :term:`primary`.
37-
3825.. versionchanged:: 2.6
3926 A new protocol for :ref:`write operations
4027 <rel-notes-write-operations>` integrates write concerns with the
@@ -59,7 +46,7 @@ Write concern can include the following fields:
5946- the :ref:`j <wc-j>` option to request acknowledgement that the write
6047 operation has been written to the journal, and
6148
62- - :ref:`wtimeout <wc-wtimeout>` option to specify a time limit to
49+ - the :ref:`wtimeout <wc-wtimeout>` option to specify a time limit to
6350 prevent write operations from blocking indefinitely.
6451
6552.. _wc-w:
@@ -74,23 +61,9 @@ propagated to a specified number of :program:`mongod` instances or to
7461Using the ``w`` option, the following ``w: <value>`` write concerns are
7562available:
7663
77- .. note::
78-
79- Standalone :program:`mongod` instances and primaries of replica sets
80- acknowledge write operations after applying the write in memory,
81- unless :ref:`j:true <wc-j>`.
82-
83- .. versionchanged:: 3.2
84-
85- For replica sets using :rsconf:`protocolVersion: 1
86- <protocolVersion>`, secondaries acknowledge write operations after
87- the secondary members have written to their respective on-disk
88- :doc:`journals </core/journaling>`, regardless of the :ref:`j
89- <wc-j>` option.
90-
9164.. list-table::
9265 :header-rows: 1
93- :widths: 25 75
66+ :widths: 20 80
9467
9568 * - Value
9669 - Description
@@ -121,66 +94,67 @@ available:
12194 request acknowledgement from specified number of members,
12295 including the primary.
12396
124- * - .. writeconcern:: "majority"
97+ See :ref:`wc-ack-behavior` for when :program:`mongod` instances
98+ acknowledge the write.
12599
126- - *Changed in version 3.2*
100+ * - .. writeconcern:: "majority"
127101
128- Requests acknowledgment that write operations have propagated to
102+ - Requests acknowledgment that write operations have propagated to
129103 the majority of voting nodes [#majority-definition]_, including
130- the primary, and have been written to the on-disk :doc:`journal
131- </core/journaling>` for these nodes.
132-
133- For replica sets using :rsconf:`protocolVersion: 1
134- <protocolVersion>`, :writeconcern:`w: "majority" <"majority">`
135- implies :ref:`j: true <wc-j>`. So, unlike ``w: <number>``, with
136- :writeconcern:`w: "majority" <"majority">`, the primary also
137- writes to the on-disk journal before acknowledging the write.
104+ the primary.
138105
139106 After the write operation returns with a :writeconcern:`w:
140107 "majority" <"majority">` acknowledgement to the client, the
141108 client can read the result of that write with a
142109 :readconcern:`"majority"` readConcern.
143110
111+ See :ref:`wc-ack-behavior` for when :program:`mongod` instances
112+ acknowledge the write.
113+
144114 * - .. writeconcern:: <tag set>
145115
146116 - Requests acknowledgement that the write operations have
147117 propagated to a replica set member with the specified :ref:`tag
148- <replica-set-configuration-tag-sets>`.
118+ <replica-set-configuration-tag-sets>`. See
119+ :ref:`wc-ack-behavior` for when :program:`mongod` instances
120+ acknowledge the write.
149121
150122.. _wc-j:
151123
152124``j`` Option
153125~~~~~~~~~~~~
154126
155- The :ref:`j <wc-j> ` option requests acknowledgement from MongoDB that
127+ The ``j` ` option requests acknowledgement from MongoDB that
156128the write operation has been written to the :doc:`journal
157129</core/journaling>`.
158130
159131.. list-table::
160- :widths: 25 75
132+ :widths: 20 80
161133
162134 * - .. writeconcern:: j
163135
164- - Requests acknowledgement that the :program:`mongod` instances, as
165- specified in the :ref:`w: \<value\> <wc-w>`, have written to the
166- on-disk journal. ``j: true`` does not by itself guarantee that
167- the write will not be rolled back due to replica set primary
168- failover.
136+ - If ``j: true``, requests acknowledgement that the
137+ :program:`mongod` instances, as specified in the :ref:`w:
138+ \<value\> <wc-w>`, have written to the on-disk journal. ``j:
139+ true`` does not by itself guarantee that the write will not be
140+ rolled back due to replica set primary failover.
169141
170142 .. versionchanged:: 3.2
171143
172144 .. include:: /includes/note-write-concern-journaled-replication.rst
173145
174- For replica sets using :rsconf:`protocolVersion: 1
175- <protocolVersion>`, :writeconcern:`w: "majority"
176- <"majority">` implies :ref:`j: true <wc-j>`,
177- if journaling is enabled. Journaling is enabled by default.
146+ .. note::
178147
179- .. versionchanged:: 2.6
180- Specifying a write concern that includes ``j: true`` to
181- a :program:`mongod` or :program:`mongos` running with
182- :option:`--nojournal` option produces an error. Previous versions would
183- ignore the ``j: true``.
148+ - Specifying a write concern that includes ``j: true`` to a
149+ :program:`mongod` instance that is running without journaling
150+ produces an error.
151+
152+ - For replica sets using :rsconf:`protocolVersion: 1
153+ <protocolVersion>`, if journaling is enabled, :writeconcern:`w:
154+ "majority" <"majority">` may imply ``j: true``. The
155+ :rsconf:`writeConcernMajorityJournalDefault` replica set
156+ configuration setting determines the behavior. See
157+ :ref:`wc-ack-behavior` for details.
184158
185159.. _wc-wtimeout:
186160
@@ -202,11 +176,99 @@ concern is unachievable, the write operation will block indefinitely.
202176Specifying a ``wtimeout`` value of ``0`` is equivalent to a write
203177concern without the ``wtimeout`` option.
204178
179+ .. _wc-ack-behavior:
180+
181+ Acknowledgement Behavior
182+ ------------------------
183+
184+ The :ref:`w <wc-w>` option and the :ref:`j <wc-j>` option determine
185+ when :program:`mongod` instances acknowledge write operations.
186+
187+ Standalone
188+ ~~~~~~~~~~
189+
190+ A standalone :program:`mongod` acknowledges a write operation either
191+ after applying the write in memory or after writing to the on-disk
192+ journal. The following table lists the acknowledgement behavior for a
193+ standalone and the relevant write concerns:
194+
195+
196+ .. list-table::
197+ :header-rows: 1
198+ :widths: 35 40 25 20
199+
200+ * -
201+ - ``j`` is unspecified
202+ - ``j:true``
203+ - ``j:false``
204+
205+ * - ``w: 1``
206+ - In memory
207+ - On-disk journal
208+ - In memory
209+
210+ * - ``w: "majority"``
211+ - On-disk journal *if running with journaling*
212+ - On-disk journal
213+ - In memory
214+
215+ Replica Sets
216+ ~~~~~~~~~~~~
217+
218+ .. versionchanged:: 3.4
219+
220+ A replica set acknowledges a write operation either after the specified
221+ number of members apply the write in memory or after they write to the
222+ on-disk journal. The number of members is specified by the :ref:`w:
223+ \<value\> <wc-w>` setting. The following table lists the
224+ acknowledgement behavior for these members and the relevant write
225+ concerns [#3.2-behavior]_:
226+
227+ .. list-table::
228+ :header-rows: 1
229+ :widths: 22 50 22 20
230+
231+ * -
232+ - ``j`` is unspecified
233+ - ``j:true``
234+ - ``j:false``
235+
236+ * - ``w: "majority"``
237+
238+ - Depends on the value of
239+ :rsconf:`writeConcernMajorityJournalDefault`.
240+
241+ - If true and the primary is running with journaling, On-disk
242+ journal.
243+
244+ - If false or the primary is not running with journaling, In
245+ memory.
246+
247+ .. versionchanged:: 3.4
248+
249+ - On-disk journal
250+
251+ - In memory
252+
253+ * - ``w: <number>``
254+
255+ - In memory
256+
257+ - On-disk journal
258+
259+ - In memory
260+
261+ .. [#3.2-behavior]
262+
263+ For the behavior in version 3.2, refer to the :v3.2:`3.2 manual
264+ </reference/write-concern>`.
265+
205266.. [#majority-definition]
206267
207268 .. versionchanged:: 3.0
208269
209- Prior to MongoDB 3.0, ``w: "majority"`` refers to the
210- majority of the replica set's members.
270+ Prior to MongoDB 3.0, ``w: "majority"`` refers to the majority of
271+ the replica set's members instead of the majority of the replica
272+ set's voting members.
211273
212274 .. include:: /includes/fact-master-slave-majority.rst
0 commit comments