-
Notifications
You must be signed in to change notification settings - Fork 406
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
Conversation
9a8703a
to
1d3f19f
Compare
ec5f6e6
to
ad34bf0
Compare
b56b13b
to
0676de3
Compare
0676de3
to
942ab2d
Compare
@huachaohuang sorry, wrong person. ^^ |
This comment has been minimized.
This comment has been minimized.
@overvenus @hicqu please take a look again. |
LGTM. 👍 Please take look at |
There was a problem hiding this 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.
@hicqu @overvenus Please consider the responses to your feedback, I have suggested new names. :) |
@overvenus thanks for the great input. :) Reflected your suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM. |
bors r+ |
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 <[email protected]> Co-authored-by: Hoverbear <[email protected]> Co-authored-by: A. Hobden <[email protected]> Co-authored-by: A. Hobden <[email protected]> Co-authored-by: qupeng <[email protected]>
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 theRaft
.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. TheProgressSet
can do this itself, and it means we can avoid having to return some enum of either(quorum)
or(new_quorum, old_quorum)
. TheRaft
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 sincepoll(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.