Quorum formula

3 views
Skip to first unread message

Luca Morandini

unread,
Jun 10, 2023, 8:05:50 AM6/10/23
to us...@couchdb.apache.org
Folks,

The doc states that the formula to get the write and read quorum is:
The default required size of a quorum is equal to r=w=((n+1)/2)
https://docs.couchdb.org/en/stable/cluster/sharding.html#quorum

However, the code suggests otherwise:
WR = N div 2 + 1,
https://github.com/apache/couchdb/blob/604526
f5f93df28138a165a666e39ff37f3fdc06/src/fabric/src/fabric_db_info.erl#L159

Am I missing something?

Cheers,

Luca Morandini

Robert Newson

unread,
Jun 11, 2023, 3:29:03 AM6/11/23
to user
Hi,

The code is definitive:

https://github.com/apache/couchdb/blob/604526f5f93df28138a165a666e39ff37f3fdc06/src/mem3/src/mem3.erl#L391

n(DbName) div 2 + 1;

That is, (N/2) + 1, where (N/2) is rounded down to nearest integer.

For odd numbers of N (the only kind we recommend) the doc formulation is equivalent due to rounding.

However, we will amend the documentation as it is wrong for even numbers (because of the lack of rounding).

Thanks for bringing this to our attention.

B.
Reply all
Reply to author
Forward
0 new messages