Conversation
By design, riak_ensemble uses leader leases which enable the leader to reply to read requests without contacting other peers in the ensemble. This is similar to the design discussed in "Paxos Made Live" [1]. To safely use leader leases, a consensus protocol must: 1. Use strong leaders. A new leader should never be able to be elected while followers are supporting an existing leader. 2. Ensure that no peers (current followers or otherwise) can be become a leader before the current leader's lease expires. The protocol used by riak_ensemble supports strong leaders, thus satisfying the first condition. The second condition is challenging, because there are very few guarantees one can make about system clocks; and even fewer that one can make between clocks on different machines. This commit hardens the leader leasing logic in riak_ensemble: -- Leases are now explicitly tracked (rather than just implicitly tracked as part of the leader tick/step_down transition). -- Worker processes now check that a lease is still valid after performing a read (rather than just before). This ensures that slow reads that complete after a lease expires are rejected. -- The new lease tracking logic verifies a lease against both Erlang corrected time [2] (using receive timeouts) as well as against the OS monotonic clock. This is the strongest guarantee we can provide without special clock hardware (eg. GPS clocks). -- Users can now set 'trust_lease = false' to force riak_ensemble to never trust leases and always perform quorum operations. -- A new quorum operation was added (check_epoch) that solely verifies the legitimacy of the current leader. Previously, not trusting the lease performed a full quorum read which is unnecessary. There is no reason not to trust the leader's local data if the leader is legitimate. [1] http://dl.acm.org/citation.cfm?id=1281103 [2] http://www.erlang.org/doc/apps/erts/time_correction.html
Move OS X timebase_info initialization in riak_ensemble_clock.c into the NIF initialization function to avoid issues with multiple threads. Correct several comment typos. Rename variables in the riak_ensemble_peer check_epoch code to make the code more clear.
Conflicts: test/TESTS
borshop
added a commit
that referenced
this pull request
Jul 12, 2014
Merge integration branch for #41 Reviewed-by: engelsanchez
Contributor
Author
|
@borshop merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bors integration pull-request for #41 which cannot be automatically merged. See #41 for full code review/discussion.