What is the definition of "majority" for a majority write?

91 views
Skip to first unread message

Richard Boyer

unread,
Aug 22, 2012, 8:01:53 PM8/22/12
to mongod...@googlegroups.com
In the documentation for getLastError it indicates that you can specify a w=majority tag to:

"wait for more than 50% of the members to acknowledge the write (until replication is applied to the point of that write)"

I'm curious what is the definition of "majority" in this context?  Is it the same as how a majority of votes is tallied for an Election, or is it something else?

My gut would say it's the majority of N where N is the total number of electable members (master, and non-hidden secondaries) but i can't find reference documentation to corroborate that.


Ref: http://www.mongodb.org/display/DOCS/getLastError+Command#getLastErrorCommand-majority


Stephen Steneker

unread,
Aug 23, 2012, 1:49:14 AM8/23/12
to mongod...@googlegroups.com
In the documentation for getLastError it indicates that you can specify a w=majority tag to:

"wait for more than 50% of the members to acknowledge the write (until replication is applied to the point of that write)"

I'm curious what is the definition of "majority" in this context?  Is it the same as how a majority of votes is tallied for an Election, or is it something else?

My gut would say it's the majority of N where N is the total number of electable members (master, and non-hidden secondaries) but i can't find reference documentation to corroborate that.

Hi Richard,

Majority in this context means "of the replica set".  This is distinct from "electable" members and voting, because arbiters do not store data .. and hidden members store data and may vote (but aren't electable).

So the normal expectation on "majority" is:  (total number of members / 2) + 1
 ... eg the majority for a 5-node replica set would be a 3 nodes (primary plus two secondaries) confirming the write

Cheers,
Stephen

Kevin Kwast

unread,
Aug 24, 2012, 5:03:07 PM8/24/12
to mongod...@googlegroups.com
So clients will get an acknowledgment of the write from a hidden node just like a non-hidden one?

Stephen Steneker

unread,
Aug 26, 2012, 10:45:35 PM8/26/12
to mongod...@googlegroups.com
On Saturday, August 25, 2012 7:03:07 AM UTC+10, Kevin Kwast wrote:
So clients will get an acknowledgment of the write from a hidden node just like a non-hidden one?

Hi Kevin,

Based on the majority write concern, clients will get confirmation that a majority of the data nodes in the replica set have written the data.  As mentioned in my previous reply, hidden nodes are still included as data nodes in the context of write concern.

To put it another way, if the majority of a 5 node set is 3 .. a majority concern indicates there are now at least 3 data nodes with a copy of the data (i.e. a primary and two secondaries).

Cheers,
Stephen
Reply all
Reply to author
Forward
0 new messages