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 Unassigned meta data #11653

Closed
wants to merge 1 commit into from
Closed

Conversation

kimchy
Copy link
Member

@kimchy kimchy commented Jun 15, 2015

Unassigned meta includes additional information as to why a shard is unassigned, this is especially handy when a shard moves to unassigned due to node leaving or shard failure.

The additional data is provided as part of the cluster state, and as part of _cat/shards API.

The additional meta includes the timestamp that the shard has moved to unassigned, allowing us in the future to build functionality such as delay allocation due to node leaving until a copy of the shard is found.

/**
* Holds additional information as to why the shard is in unassigned state.
*/
public class UnassignedMeta implements ToXContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should implement org.elasticsearch.common.io.stream.Writeable and then this can all be final as well without the static read write methods

Copy link
Member Author

Choose a reason for hiding this comment

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

The fields are final, I opted for this compared to Writeable solution since then I would have needed to create PROTO and such, this class has no meaning outside of shard routing, so this makes the solution simpler I think

Copy link
Contributor

Choose a reason for hiding this comment

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

no PROTO needed that is purely optional. you just pass the StreamInput to the ctor which would look like this new UnassignedMeta(streamInput) and everything stays final, no proto required at all. I think we should not have yet another way to serialize and we are moving towards Writeable so this one should implement it as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@s1monw
Copy link
Contributor

s1monw commented Jun 15, 2015

left some minor comments mainly structural... good change!

@@ -224,6 +246,11 @@ public void readFromThin(StreamInput in) throws IOException {
state = ShardRoutingState.fromValue(in.readByte());

restoreSource = RestoreSource.readOptionalRestoreSource(in);
if (in.getVersion().onOrAfter(Version.V_1_7_0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

de we want a default non-null value here?

Copy link
Contributor

Choose a reason for hiding this comment

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

please ignore - misread the constructor - seems like a null is a valid value.

@clintongormley
Copy link

Awesome change, but it's missing documentation?

/**
* A fresh shard routing, never been assigned.
*/
NEW((byte) 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be handy, for future changes, to make a distinction between shards that were just created via create index api calls (and thus can be assigned anywhere) and ones that were recovered from a cluster state on disk but still need assigned (for which we want to do some effort and find a copy)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, bitting the bullet mode engaged :)

@bleskes
Copy link
Contributor

bleskes commented Jun 15, 2015

+1 - left a couple of minor comments, plus a suggestion to split the Reason.NEW into "new from API" and recovered.

@kimchy
Copy link
Member Author

kimchy commented Jun 15, 2015

I implemented the first round of feedback, biggest change is several additional reasons for unassigned (quite a few actually :) ), and now its verified that when a shard is created unassigned, we provide the meta data for it

@kimchy
Copy link
Member Author

kimchy commented Jun 15, 2015

also, would love to hear if the names I came up with for Reason make sense (https://github.com/elastic/elasticsearch/pull/11653/files#diff-d0e0ede81cd92c4e0b6b707b254f5fcaR45)

/**
* A new shard created as a result of a cluster recovery.
*/
NEW_RECOVERY,
Copy link
Contributor

Choose a reason for hiding this comment

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

what is a cluster recovery again? I find this really confusing as a name... not sure about an alternative but maybe you can explain when it happens and I can suggest something

Copy link
Member Author

Choose a reason for hiding this comment

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

this happens during a full cluster restart, when the shards are unassigned because they got important as part of the initial cluster recovery process, mmm, maybe I can change NEW_API to NEW, and NEW_RECOVER to CLUSTER_RECOVERY, will try it out

}

/**
* Initializes a new empty index, as if it was created from an API.
Copy link
Contributor

Choose a reason for hiding this comment

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

comment copy paste issue

@bleskes
Copy link
Contributor

bleskes commented Jun 16, 2015

LGTM. Left some minor suggestions.

@s1monw
Copy link
Contributor

s1monw commented Jun 16, 2015

this also LGTM the only thing that I really don't like is the UnassignedMeta name. everything that has Meta attached to it is like a smell to it that it rather belongs somewhere else. I think we should rename the class to something like UnassignmentEvent or something like this or maybe UnassignedTrigger something that makes it clear that we are tracking the cause of the unassignemnet.

@kimchy
Copy link
Member Author

kimchy commented Jun 16, 2015

pushed the first round of better names (not yet for UnassignedMeta), and addressed comments

@bleskes
Copy link
Contributor

bleskes commented Jun 16, 2015

Namings LGTM. My vote goes to UnassignmentInfo (I like unassignment as it doesn't suggest it is unassigned now, Meta and Info are the same imho). I don't feel strongly about this and I'm good with all of the above as well.

@s1monw
Copy link
Contributor

s1monw commented Jun 16, 2015

ok with UnassignmentInfo or UnassignmentEvent but I am leaning towards the latter

Unassigned meta includes additional information as to why a shard is unassigned, this is especially handy when a shard moves to unassigned due to node leaving or shard failure.

The additional data is provided as part of the cluster state, and as part of `_cat/shards` API.

The additional meta includes the timestamp that the shard has moved to unassigned, allowing us in the future to build functionality such as delay allocation due to node leaving until a copy of the shard is found.
closes elastic#11653
@kimchy
Copy link
Member Author

kimchy commented Jun 16, 2015

renamed to UnassignedInfo, I think its the best suggestion so far, will push soonish

@kimchy kimchy closed this in 4e0d654 Jun 16, 2015
@kevinkluge kevinkluge removed the review label Jun 16, 2015
kimchy added a commit that referenced this pull request Jun 16, 2015
Unassigned meta includes additional information as to why a shard is unassigned, this is especially handy when a shard moves to unassigned due to node leaving or shard failure.

The additional data is provided as part of the cluster state, and as part of `_cat/shards` API.

The additional meta includes the timestamp that the shard has moved to unassigned, allowing us in the future to build functionality such as delay allocation due to node leaving until a copy of the shard is found.
closes #11653
@kimchy kimchy deleted the unassigned_meta branch June 16, 2015 18:26
@clintongormley clintongormley added :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. and removed :Cluster labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. >enhancement v1.7.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants