Skip to content

Write next cluster state fully on all failures #73631

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

Conversation

DaveCTurner
Copy link
Contributor

Today we do not set the LucenePersistedState#writeNextStateFully flag
on all failures, notably on an OutOfMemoryError. Since we don't exit
immediately on an OOME we may have failed part-way through writing a
full state but still proceed with another apparently-incremental write.

With this commit we ensure LucenePersistedState#writeNextStateFully is
only set if the previous write was successful.

Today we do not set the `LucenePersistedState#writeNextStateFully` flag
on all failures, notably on an `OutOfMemoryError`. Since we don't exit
immediately on an OOME we may have failed part-way through writing a
full state but still proceed with another apparently-incremental write.

With this commit we ensure `LucenePersistedState#writeNextStateFully` is
only set if the previous write was successful.
@DaveCTurner DaveCTurner added >bug :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v8.0.0 v7.14.0 v7.13.2 labels Jun 1, 2021
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Jun 1, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM.

Ideally we would add a test that also exercises an Error in writeIncrementalStateAndCommit and writeIncrementalTermUpdateAndCommit. The former is probably "easy" since it also uses big arrays, whereas I can see the latter needing to mock more. I think this can go in without it though if you prefer.

@DaveCTurner
Copy link
Contributor Author

👍 I generalised the test to behave a bit more randomly to cover a few more branches, see f04ea2f.

There's no easy way to test the term update. I pondered the failure modes of commit() and think it might have a similar problem, although much rarer because it does almost nothing outside of Lucene code so an OOME is more likely tragic to the writer. If however it hits a non-tragic OOME then we might have called prepareCommit() and then the next time round call prepareCommit() again, perhaps after writing some more docs. I think this is ultimately ok, the second time round it'll throw an IllegalStateException and close the writer rather than breaking anything.

@DaveCTurner DaveCTurner merged commit f1abcf1 into elastic:master Jun 2, 2021
@DaveCTurner DaveCTurner deleted the 2021-06-01-write-next-state-fully-on-failure branch June 2, 2021 10:18
DaveCTurner added a commit that referenced this pull request Jun 2, 2021
Today we do not set the `LucenePersistedState#writeNextStateFully` flag
on all failures, notably on an `OutOfMemoryError`. Since we don't exit
immediately on an OOME we may have failed part-way through writing a
full state but still proceed with another apparently-incremental write.

With this commit we ensure `LucenePersistedState#writeNextStateFully` is
only set if the previous write was successful.
DaveCTurner added a commit that referenced this pull request Jun 2, 2021
Today we do not set the `LucenePersistedState#writeNextStateFully` flag
on all failures, notably on an `OutOfMemoryError`. Since we don't exit
immediately on an OOME we may have failed part-way through writing a
full state but still proceed with another apparently-incremental write.

With this commit we ensure `LucenePersistedState#writeNextStateFully` is
only set if the previous write was successful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.13.2 v7.14.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants