basho/riak_core — pull request #601 by jtuple (2014-06-05 23:55:17+00:00)
Title: Add logic to automatically enable consensus system

Currently, in addition to enabling consensus in app.config, a user must
also manually call `riak_ensemble_manager:enable()` from one and only
one node in a cluster to activate the consensus sub-system. This is
necessary to ensure that there is only a single logical root ensemble
history -- all other nodes adopt the history from the single enabled
node.

However, this step is not only annoying but also error-prone. Enabling
consensus on multiple nodes can break the consensus system, requiring
manual intervention.

This commit addresses this problem by making riak_core automatically
enable the consensus system in a safe way. This is accomplished by
having the claimant node enable the consensus system. To avoid the
issue where the claimant in multiple 1-node clusters enables consensus
before being joined, this commit requires the cluster to have at least
three nodes before the claimant will enable the consensus system.

To prevent a race during claimant changes, a claimant must first write
a special ring metadata value that prevents future claimants from
activating the consensus system. It is not until after the ring has
converged cluster wide, and the claimant sees the appropriate metadata
value, that the claimant activates the consensus system.

Resolves #571