# Why does ClusterState class need need a data member named stateUUID?

**URL:** <https://discuss.elastic.co/t/why-does-clusterstate-class-need-need-a-data-member-named-stateuuid/295196>\
**Category:** Elasticsearch\
**Created:** [January 24, 2022, 8:43am UTC](https://discuss.elastic.co/t/why-does-clusterstate-class-need-need-a-data-member-named-stateuuid/295196 "2022-01-24T08:43:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![armsword](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armsword/32/92690_2.png) [@armsword](https://discuss.elastic.co/u/armsword)\
**Post date:** [January 24, 2022, 8:43am UTC](https://discuss.elastic.co/t/why-does-clusterstate-class-need-need-a-data-member-named-stateuuid/295196/1 "2022-01-24T08:43:21Z")

</div>

[https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/cluster/ClusterState.java#L139](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/cluster/ClusterState.java#L139)

This class `ClusterState` has two data member, named `stateUUID` and `version`. The `stateUUID` is supported for cluster state diffs. My question is since there is a `version` member, why do need a `stateUUID` data member? The `version` data member can also support the cluster state diffs.

@Igor_Motov Thanks.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [January 24, 2022, 5:48pm UTC](https://discuss.elastic.co/t/why-does-clusterstate-class-need-need-a-data-member-named-stateuuid/295196/2 "2022-01-24T17:48:05Z")

</div>

Version is monotonically increasing on (and therefore uniquely identifies) **committed** states, while stateUUID uniquely identifies a state, even if the state is not committed. Typically, stateUUID is used to identify changed state when it received by non-master nodes before the state is committed, you can think of it as non-commited version. During normal operation of cluster each new stateUUID will have a corresponding version change, but when something unordinary happens such as master disconnects, nodes go down or timeout, etc, there could be multiple different states with different stateUUIDs before one of them is finally accepted by the quorum of master-eligible nodes and the version increments. You can find more information about this process and parameters that control it in our [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/cluster-state-publishing.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 21, 2022, 5:48pm UTC](https://discuss.elastic.co/t/why-does-clusterstate-class-need-need-a-data-member-named-stateuuid/295196/3 "2022-02-21T17:48:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
