Replica Sets - Priority

By default, all full nodes in a replica set have equal priority. If a primary steps down, all other members are electable as the new primary. That is, each node by default has priority:1.

  • Arbiters have no data, and are never a primary (or even a read-only secondary). Thus priority has no meaning on arbiters.
  • Members with the hidden:true property must have priority:0

MongoDB v2.0+ provides more fine-grained control over priorities.

Priority 0 nodes

A node with priority:0 can never become primary. Typical uses:

  • a less powerful server might be suitable to be a secondary but not primary
  • a server in a secondary data center where one wants only manual fail-over (common for disaster recovery)
  • a server used for taking backups
  • a time-delayed secondary (slaveDelay property)

v1.6-1.8

In v1.6-1.8, the priority of a node can be zero or one only.

v2.0+ : specific priorities

As of v2.0, members can have more granular priorities (values between zero and one thousand, e.g., 673.2).

When an election is triggered, the highest priority amongst the most up-to-date nodes will be elected.

  • "up-to-date" implies within 10 seconds of the primary. This is not configurable
  • Note - if a node with a higher priority than the primary "catches up", this will trigger a new election (which the higher priority node will win)

Example: if B and C are candidates in an election, B having a higher priority but C being the most up to date:

  1. C will be elected primary
  2. Once B catches up a re-election should be triggered and B (the higher priority node) should win the election between B and C
  3. Alternatively, suppose that once B is within 12 seconds of sync with C, C goes down.
    • B will be elected primary.
    • When C comes back up, those 12 seconds of unsynced writes will be written to a file in the rollback directory of your data directory (rollback is created when needed).
    • You can manually apply the rolled-back data; see Replica Sets - Rollbacks.

See Also

Follow @mongodb

MongoDB Pittsburgh - May 15
MongoNYC - May 23
MongoDB Paris - Jun 14
MongoDB UK - Jun 20
MongoDC - June 26


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus