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

Add term and config to cluster state #32100

Merged
merged 9 commits into from
Jul 17, 2018

Conversation

ywelsch
Copy link
Contributor

@ywelsch ywelsch commented Jul 16, 2018

Adds the publication term and the last accepted and committed configurations to the cluster state, following the formal model in https://github.com/elastic/elasticsearch-formal-models/blob/master/ZenWithTerms/tla/ZenWithTerms.tla
The term represents the reign of a master, and the last committed / accepted configurations represent the set of quorums that cluster state changes will require (If there's no reconfiguration, last accepted and last committed configurations coincide).
We might end up shifting the last committed and last accepted configuration to a different sub-object of the cluster state (e.g. MetaData), but this depends mainly on the storage system that we will chose further down the line. The most natural object for now is the main cluster state object.

Relates to #32006

@ywelsch ywelsch added >enhancement v7.0.0 :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. labels Jul 16, 2018
@ywelsch ywelsch requested a review from DaveCTurner July 16, 2018 15:52
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Asked for a few more tests around VotingConfiguration. Also I would slightly prefer term to come ahead of version throughout, certainly in display but also really in other serialisations.

}

public void testVotingConfiguration() {
ClusterState.VotingConfiguration config0 = new ClusterState.VotingConfiguration(Sets.newHashSet());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also assert that this is .equals(VotingConfiguration.EMPTY_CONFIG)?

assertThat(config3.hasQuorum(Sets.newHashSet("id2")), equalTo(false));
assertThat(config3.hasQuorum(Sets.newHashSet("id3")), equalTo(false));
assertThat(config3.hasQuorum(Sets.newHashSet("id1", "id4")), equalTo(false));
assertThat(config3.hasQuorum(Sets.newHashSet()), equalTo(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also assertThat(config3.hasQuorum(Sets.newHashSet("id1", "id4", "id5")), equalTo(false));?

}

@Override
public boolean equals(Object o) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any assertions that this works - specifically that it ever returns false. Could we have some?


@Override
public int hashCode() {
return Objects.hash(nodeIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an easy way to assert that this is consistent with equals()?

@ywelsch ywelsch mentioned this pull request Jul 17, 2018
61 tasks
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Missed one (unimportant) term <-> version swap, but LGTM apart from that. TIL EqualsHashCodeTestUtils.checkEqualsAndHashCode 😄

@@ -77,7 +77,10 @@ protected void masterOperation(final ClusterStateRequest request, final ClusterS
logger.trace("Serving cluster state request using version {}", currentState.version());
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
builder.version(currentState.version());
builder.term(currentState.term());
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed a term<->version swap.

@ywelsch ywelsch merged commit ad78f73 into elastic:zen2 Jul 17, 2018
@ywelsch
Copy link
Contributor Author

ywelsch commented Jul 17, 2018

Thanks @DaveCTurner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. >enhancement v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants