[SERVER-55687] Add function to calculate write concern default formula Created: 01/Apr/21  Updated: 29/Oct/23  Resolved: 26/Apr/21

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Samyukta Lanka Assignee: Moustafa Maher
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-55688 Keep track of implicit default write ... Closed
Related
Backwards Compatibility: Minor Change
Sprint: Repl 2021-04-19, Repl 2021-05-03
Participants:

 Description   

implicitDefaultWriteConcern = if ((#arbiters > 0) AND (#arbiters >= ½(#voting nodes) - 1)) then {w:1} else {w:majority}.

We should keep track of the implicit default write concern in ReadWriteConcernDefaults. _getDefault cannot return the implicit default write concern yet however (that will happen in SERVER-55703), since that has implications for sharded clusters that we have to resolve first.



 Comments   
Comment by Moustafa Maher [ 24/Aug/21 ]

A better way to state the formula:

  • If the number of data-bearing voting members is not strictly more than the voting majority, the default write concern is w: 1.
  • In all other scenarios, the default write concern is w: "majority".
if ((#arbiters > 0) AND (#non-arbiters <= majority(#voting nodes))
    defaultWriteConcern = { w: 1 }
else
     defaultWriteConcern = { w: majority }

majority(#voting nodes) = (voting nodes)/2 + 1

Example:  

#non-arbiters #arbiters #voting nodes majority(#voting nodes) IDWC
1 1 2 2 W:1
2 1 3 2 W:1
3 1 4 3 W:1
4 1 5 3 W:Majority
5 1 6 4 W:Majority
6 1 7 4 W:Majority
1 2 3 2 W:1
2 2 4 3 W:1
3 2 5 3 W:1
4 2 6 4 W:1
5 2 7 4 W:Majority
1 3 4 3 W:1
2 3 5 3 W:1
3 3 6 4 W:1
4 3 7 4 W:1
1 4 5 3 W:1
2 4 6 4 W:1
3 4 7 4 W:1
1 5 6 4 W:1
2 5 7 4 W:1
1 6 7 4 W:1
Comment by Githook User [ 20/Apr/21 ]

Author:

{'name': 'Moustafa Maher', 'email': 'm.maher@10gen.com', 'username': 'moustafamaher'}

Message: SERVER-55687 Add function to calculate write concern default formula
Branch: master
https://github.com/mongodb/mongo/commit/1faca42eecf27fa515ac8db3d1674af1b298cdc2

Generated at Thu Feb 08 05:37:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.