Skip to content

Commit 92ed80e

Browse files
committed
DOCS-7138, DOCS-8576 majority write concern and default journaling behavior
1 parent 8390030 commit 92ed80e

File tree

5 files changed

+180
-63
lines changed

5 files changed

+180
-63
lines changed

source/includes/replica-set-conf-document-output.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include only a subset of these settings:
88
_id: <string>,
99
version: <int>,
1010
protocolVersion: <number>,
11+
writeConcernMajorityJournalDefault: <boolean>,
1112
members: [
1213
{
1314
_id: <int>,

source/reference/glossary.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,9 @@ Glossary
282282
considered durable when it has been written to the server's
283283
:term:`journal` file. For a :doc:`replica set
284284
</replication>`, a write operation is
285-
considerable durable once the write operation is durable on a
286-
:writeconcern:`majority of voting nodes <"majority">` in the
287-
replica set; i.e. written to a majority of voting nodes' journal
288-
files.
285+
considered durable once the write operation is durable on a
286+
majority of voting nodes; i.e. written to a majority of voting
287+
nodes' journals.
289288

290289
election
291290
The process by which members of a :term:`replica set` select a

source/reference/replica-configuration.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,46 @@ Replica Set Configuration Fields
8686
cannot run as members of a replica set configuration that specifies
8787
``protocolVersion`` 1.
8888

89+
.. rsconf:: writeConcernMajorityJournalDefault
90+
91+
.. versionadded:: 3.4
92+
93+
*Type*: boolean
94+
95+
*Default*: true if ``protocolVersion`` is 1 and false if ``protocolVersion`` is 0
96+
97+
Determines the behavior of :writeconcern:`{ w: "majority" }
98+
<"majority">` write concern if the write concern does not explicitly
99+
specify the journal option :ref:`j <wc-j>`:
100+
101+
.. list-table::
102+
:header-rows: 1
103+
104+
* - ``writeConcernMajorityJournalDefault``
105+
- ``{ w: "majority" }`` Behavior
106+
107+
* - true
108+
109+
- MongoDB acknowledges the write operation after a majority of
110+
the voting members have written to the on-disk journal *if*
111+
the primary of the replica set is running with journaling.
112+
113+
If true but the primary of the replica set is not running with
114+
journaling, MongoDB acknowledges the operation after a
115+
majority of the voting members have applied the operations in
116+
memory.
117+
118+
* - false
119+
120+
- MongoDB acknowledges the write operation after a majority of
121+
the voting members have applied the operation in
122+
memory.
123+
124+
If :ref:`j <wc-j>` is specified in the write concern, MongoDB uses
125+
the :ref:`journal <wc-j>` behavior specified in the write concern.
126+
127+
.. seealso:: :ref:`wc-ack-behavior`
128+
89129
``members``
90130
~~~~~~~~~~~
91131

source/reference/write-concern.txt

Lines changed: 121 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@ MongoDB for write operations to a standalone :program:`mongod` or to
2222
sharded clusters, :program:`mongos` instances will pass the write
2323
concern 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
7461
Using the ``w`` option, the following ``w: <value>`` write concerns are
7562
available:
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
156128
the 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.
202176
Specifying a ``wtimeout`` value of ``0`` is equivalent to a write
203177
concern 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

source/release-notes/3.4.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ To support zones, MongoDB introduces the following commands and
102102
- | :method:`sh.updateZoneKeyRange()`
103103
| :method:`sh.removeRangeFromZone()`
104104

105+
.. _3.4-replica-set:
106+
107+
Replica Set
108+
-----------
109+
110+
Default Journaling Behavior of ``majority`` Write Concern
111+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112+
113+
A new replica set configuration setting
114+
:rsconf:`writeConcernMajorityJournalDefault` determines whether an
115+
acknowledgement for a write concern of :writeconcern:`majority
116+
<"majority">` returns after the majority of the voting members apply
117+
the write in memory or to the on-disk journal *if* the :ref:`j <wc-j>`
118+
option is unspecified in the write concern.
119+
105120
.. _3.4-decimal:
106121

107122
Decimal Type

0 commit comments

Comments
 (0)