Managing Election Times

Where it comes to elections, there are two timeout values with which you should be concerned: election timeouts and election retries.

Managing Election Timeouts

When a environment calls for an election, it will wait some amount of time for the other replicas in the replication group to respond. The amount of time that the environment will wait before declaring the election completed is the election timeout.

If the environment hears from all other known replicas before the election timeout occurs, the election is considered a success and a master is elected.

If only a subset of replicas respond, then the success or failure of the election is determined by (1) how many replicas have responded and (2) the election policy that is in place at the time. For example, usually it only takes a simple majority of replicas to elect a master. If there are enough votes for a given environment to meet that standard, then the master has been elected and the election is considered a success.

However, upon application startup you can require that all known replicas must participate in the election. Or, it is possible that not enough votes are cast to select a master even with a simple majority. If either of these conditions occur when the election timeout value is reached, the election is considered a failure and a master is not elected. At this point, your replication group is operating without a master, which means that, essentially, your replicated application has been placed in read-only mode.

Note, however, that the replication framework will attempt a new election after a given amount of time has passed. See the next section for details.

You set the election timeout value using DB_ENV->rep_set_timeout(). To do so, specify the DB_REP_ELECTION_TIMEOUT flag to the which parameter and then a timeout value in microseconds to the timeout parameter.

Managing Election Retry Times

In the event that a election fails (see the previous section), an election will not be attempted again until the election retry timeout value has expired.

You set the retry timeout value using DB_ENV->rep_set_timeout(). To do so, specify the DB_REP_ELECTION_RETRY flag to the which parameter and then a retry value in microseconds to the timeout parameter.