Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move poll & quorum functionality into ProgressSet #121

Merged
merged 26 commits into from
Nov 21, 2018
Merged

Conversation

Hoverbear
Copy link
Contributor

@Hoverbear Hoverbear commented Sep 12, 2018

Based off #119. You are seeing that change set as well here, so go review that, then this after merging it! :)

Migrate poll and quorum related functionality inside ProgressSet.

These functions operated on the ProgressSet anyways, they were just scoped to the Raft.

Rationale

With the introduction of Joint Consensus, the idea of a Quorum is no longer always a single value. (If the cluster is in a joint state it actually has two quorums. The old configuration and the new one.)

In the interest of isolating responsibility and dulling sharp edges, this PR migrates code the following functionality:

  • check_quorum_active: Migrated, it was doing a mutable fold on the peers and resetting their recent active, then returning if there was enough for quorum. The ProgressSet can do this itself, and it means we can avoid having to return some enum of either (quorum) or (new_quorum, old_quorum). The Raft module need not care.
  • poll: Was split into a mutating vote-setter function, and a check function (non mutating). The check function returns a semantically meaningful enum now. This was a good idea since poll(vote) >= quorum, while still valid, may be comparing tuples or values. Internalizing this logic and instead returning a semantic value helps with understanding.
  • minimum_committed_index: Since in a joint consensus state we need to check the minimum committed index of both old and new, we can internalize this check and just return a bool.

Benefits

This PR essentially amounts to API cleaning. It doesn't change any behavior, but it's a change we should do to make future work easier.

Future Work

When Joint Consensus (#101 ) lands it will change these new functions to be joint-aware and correctly return values regardless of the configuration state.

@Hoverbear Hoverbear added the Enhancement An improvement to existing code. label Sep 12, 2018
@Hoverbear Hoverbear added this to the 0.5.0 milestone Sep 12, 2018
@Hoverbear Hoverbear self-assigned this Sep 12, 2018
@Hoverbear Hoverbear changed the title Move poll quorum Move poll & quorum functionality into ProgressSet Sep 12, 2018
@Hoverbear Hoverbear added the Feature Related to a major feature. label Sep 12, 2018
@Hoverbear Hoverbear added this to To do in Joint Consensus Sep 12, 2018
@Hoverbear Hoverbear moved this from To do to Needs review in Joint Consensus Sep 12, 2018
@Hoverbear Hoverbear force-pushed the move-poll-quorum branch 6 times, most recently from 9a8703a to 1d3f19f Compare September 19, 2018 00:40
@Hoverbear Hoverbear force-pushed the move-poll-quorum branch 3 times, most recently from ec5f6e6 to ad34bf0 Compare September 26, 2018 17:20
@Hoverbear Hoverbear force-pushed the move-poll-quorum branch 3 times, most recently from b56b13b to 0676de3 Compare September 27, 2018 18:11
src/progress.rs Outdated Show resolved Hide resolved
src/progress.rs Outdated Show resolved Hide resolved
src/progress.rs Outdated Show resolved Hide resolved
src/progress.rs Outdated Show resolved Hide resolved
@Hoverbear Hoverbear requested review from hicqu and removed request for huachaohuang October 30, 2018 14:30
@Hoverbear
Copy link
Contributor Author

@huachaohuang sorry, wrong person. ^^

src/raft.rs Outdated Show resolved Hide resolved
bors bot added a commit that referenced this pull request Nov 1, 2018
@bors

This comment has been minimized.

@Hoverbear
Copy link
Contributor Author

@overvenus @hicqu please take a look again.

hicqu
hicqu previously approved these changes Nov 8, 2018
@hicqu
Copy link
Contributor

hicqu commented Nov 8, 2018

LGTM. 👍 Please take look at fn poll. Maybe we should rename it.

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments, overall LGTM.

src/progress.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
@Hoverbear
Copy link
Contributor Author

@hicqu @overvenus Please consider the responses to your feedback, I have suggested new names. :)

@Hoverbear
Copy link
Contributor Author

@overvenus thanks for the great input. :) Reflected your suggestion.

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Joint Consensus automation moved this from Needs review to Reviewer approved Nov 21, 2018
@hicqu
Copy link
Contributor

hicqu commented Nov 21, 2018

LGTM.

@Hoverbear
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Nov 21, 2018
121: Move poll & quorum functionality into ProgressSet r=Hoverbear a=Hoverbear

Based off #119. **You are seeing that change set as well here, so go review that, then this after merging it! :)**

Migrate poll and quorum related functionality inside `ProgressSet`.

These functions operated on the `ProgressSet` anyways, they were just scoped to the `Raft`.

# Rationale

With the introduction of Joint Consensus, the idea of a Quorum is no longer always a single value. (If the cluster is in a joint state it actually has two quorums. The old configuration and the new one.)

In the interest of isolating responsibility and dulling sharp edges, this PR migrates code the following functionality:

* `check_quorum_active`: Migrated, it was doing a mutable fold on the peers and resetting their recent active, then returning if there was enough for quorum. The `ProgressSet` can do this itself, and it means we can avoid having to return some enum of either `(quorum)` or `(new_quorum, old_quorum)`. The `Raft` module need not care.
* `poll`: Was split into a mutating vote-setter function, and a check function (non mutating). The check function returns a semantically meaningful enum now. This was a good idea since `poll(vote) >= quorum`, while still valid, may be comparing tuples or values. Internalizing this logic and instead returning a semantic value helps with understanding.
* `minimum_committed_index`: Since in a joint consensus state we need to check the minimum committed index of both old and new, we can internalize this check and just return a bool.

# Benefits

This PR essentially amounts to API cleaning. It doesn't change any behavior, but it's a change we should do to make future work easier.

# Future Work

When Joint Consensus (#101 ) lands it will change these new functions to be joint-aware and correctly return values regardless of the configuration state.

Co-authored-by: Hoverbear <andrew@hoverbear.org>
Co-authored-by: Hoverbear <operator@hoverbear.org>
Co-authored-by: A. Hobden <andrew@hoverbear.org>
Co-authored-by: A. Hobden <operator@hoverbear.org>
Co-authored-by: qupeng <onlyqupeng@gmail.com>
@bors
Copy link
Contributor

bors bot commented Nov 21, 2018

@bors bors bot merged commit 5880c33 into master Nov 21, 2018
Joint Consensus automation moved this from Reviewer approved to Done Nov 21, 2018
@Hoverbear Hoverbear deleted the move-poll-quorum branch November 21, 2018 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement An improvement to existing code. Feature Related to a major feature.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants