@@ -22,19 +22,6 @@ MongoDB for write operations to a standalone :program:`mongod` or to
22
22
sharded clusters, :program:`mongos` instances will pass the write
23
23
concern on to the shards.
24
24
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
-
38
25
.. versionchanged:: 2.6
39
26
A new protocol for :ref:`write operations
40
27
<rel-notes-write-operations>` integrates write concerns with the
@@ -59,7 +46,7 @@ Write concern can include the following fields:
59
46
- the :ref:`j <wc-j>` option to request acknowledgement that the write
60
47
operation has been written to the journal, and
61
48
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
63
50
prevent write operations from blocking indefinitely.
64
51
65
52
.. _wc-w:
@@ -74,23 +61,9 @@ propagated to a specified number of :program:`mongod` instances or to
74
61
Using the ``w`` option, the following ``w: <value>`` write concerns are
75
62
available:
76
63
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
-
91
64
.. list-table::
92
65
:header-rows: 1
93
- :widths: 25 75
66
+ :widths: 20 80
94
67
95
68
* - Value
96
69
- Description
@@ -121,66 +94,67 @@ available:
121
94
request acknowledgement from specified number of members,
122
95
including the primary.
123
96
124
- * - .. writeconcern:: "majority"
97
+ See :ref:`wc-ack-behavior` for when :program:`mongod` instances
98
+ acknowledge the write.
125
99
126
- - *Changed in version 3.2*
100
+ * - .. writeconcern:: "majority"
127
101
128
- Requests acknowledgment that write operations have propagated to
102
+ - Requests acknowledgment that write operations have propagated to
129
103
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.
138
105
139
106
After the write operation returns with a :writeconcern:`w:
140
107
"majority" <"majority">` acknowledgement to the client, the
141
108
client can read the result of that write with a
142
109
:readconcern:`"majority"` readConcern.
143
110
111
+ See :ref:`wc-ack-behavior` for when :program:`mongod` instances
112
+ acknowledge the write.
113
+
144
114
* - .. writeconcern:: <tag set>
145
115
146
116
- Requests acknowledgement that the write operations have
147
117
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.
149
121
150
122
.. _wc-j:
151
123
152
124
``j`` Option
153
125
~~~~~~~~~~~~
154
126
155
- The :ref:`j <wc-j> ` option requests acknowledgement from MongoDB that
127
+ The ``j` ` option requests acknowledgement from MongoDB that
156
128
the write operation has been written to the :doc:`journal
157
129
</core/journaling>`.
158
130
159
131
.. list-table::
160
- :widths: 25 75
132
+ :widths: 20 80
161
133
162
134
* - .. writeconcern:: j
163
135
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.
169
141
170
142
.. versionchanged:: 3.2
171
143
172
144
.. include:: /includes/note-write-concern-journaled-replication.rst
173
145
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::
178
147
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.
184
158
185
159
.. _wc-wtimeout:
186
160
@@ -202,11 +176,99 @@ concern is unachievable, the write operation will block indefinitely.
202
176
Specifying a ``wtimeout`` value of ``0`` is equivalent to a write
203
177
concern without the ``wtimeout`` option.
204
178
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
+
205
266
.. [#majority-definition]
206
267
207
268
.. versionchanged:: 3.0
208
269
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.
211
273
212
274
.. include:: /includes/fact-master-slave-majority.rst
0 commit comments