@@ -3,19 +3,57 @@ Starting in MongoDB 5.0, the implicit default write concern is
3
3
considerations are made for deployments containing :ref: `arbiters
4
4
<replica-set-arbiter-configuration>`:
5
5
6
- - If the number of data-bearing voting members is not strictly more
7
- than the voting majority, the default write concern is ``w: 1 ``.
6
+ - The voting majority of a replica set is 1 plus half the number of
7
+ voting members, rounded down. If the number of data-bearing voting
8
+ members is not greater than the voting majority, the default write
9
+ concern is ``{ w: 1 } ``.
8
10
9
- - In all other scenarios, the default write concern is ``w:
10
- "majority" ``.
11
+ - In all other scenarios, the default write concern is ``{ w:
12
+ "majority" } ``.
11
13
12
14
Specifically, MongoDB uses the following formula to determine the
13
15
default write concern:
14
16
15
17
.. code-block :: none
16
18
:copyable: false
17
19
18
- if [(#arbiters > 0) AND (#arbiters >= ½ (#voting nodes) - 1) ]
20
+ if [ (#arbiters > 0) AND (#non- arbiters <= majority (#voting- nodes)) ]
19
21
defaultWriteConcern = { w: 1 }
20
22
else
21
- defaultWriteConcern = { w: majority }
23
+ defaultWriteConcern = { w: "majority" }
24
+
25
+ For example, consider the following deployments and their respective
26
+ default write concerns:
27
+
28
+ .. list-table ::
29
+ :header-rows: 1
30
+
31
+ * - Non-Arbiters
32
+ - Arbiters
33
+ - Voting Nodes
34
+ - Majority of Voting Nodes
35
+ - Implicit Default Write Concern
36
+
37
+ * - 3
38
+ - 1
39
+ - 4
40
+ - 3
41
+ - ``{ w: 1 } ``
42
+
43
+ * - 4
44
+ - 1
45
+ - 5
46
+ - 3
47
+ - ``{ w: "majority" } ``
48
+
49
+ - The first example has 3 non-arbiters and 1 arbiter for a total of 4
50
+ voting nodes. The majority of voting nodes (1 plus half of 4) is 3.
51
+ The number of non-arbiters (3) is less than or equal to the majority
52
+ of voting nodes, resulting in an implicit write concern of
53
+ ``{ w: 1 } ``.
54
+
55
+ - The second example has 4 non-arbiters and 1 arbiter for a total of 5
56
+ voting nodes. The majority of voting nodes (1 plus half of 5, rounded
57
+ down) is 3. The number of non-arbiters (4) is greater than the majority
58
+ of voting nodes, resulting in an implicit write concern of ``{ w:
59
+ "majority" } ``.
0 commit comments