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

Introduce constants for special ReservedClusterStateMetadata versions #107995

Merged
merged 3 commits into from May 7, 2024

Conversation

mosche
Copy link
Contributor

@mosche mosche commented Apr 29, 2024

Introducing constants for special ReservedClusterStateMetadata versions to make it easier to trace their usage.

@mosche mosche added >non-issue :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team labels Apr 29, 2024
@mosche mosche requested a review from rjernst April 29, 2024 08:05
@mosche mosche marked this pull request as ready for review April 29, 2024 11:18
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

One little question/suggestion, but looks good

@@ -50,7 +51,7 @@ ActionListener<ActionResponse.Empty> listener() {
static boolean isNewError(ReservedStateMetadata existingMetadata, Long newStateVersion) {
return (existingMetadata == null
|| existingMetadata.errorMetadata() == null
|| newStateVersion <= 0 // version will be -1 when we can't even parse the file, it might be 0 on snapshot restore
|| newStateVersion <= RESTORED_VERSION // Long.MIN_VALUE (no version) when we can't parse the file, 0 on snapshot restore
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 there are no other cases, if
newStateVersion == RESTORED_VERSION || newStateVersion == EMPTY_VERSION is more clear (you could get rid of the comment, which is usually a good indication)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this as well, and agree it would add clarity. At the same time I'm worried this would easily break things if more magic version ids are introduced. I'll think a bit more about it....

Copy link
Member

Choose a reason for hiding this comment

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

Can we enforce the version for error metadata is > 0 when explicitly initialized (ie with a real error)?

Copy link
Contributor Author

@mosche mosche May 7, 2024

Choose a reason for hiding this comment

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

@rjernst I had another look at this, I think it's tricky to make any changes on error metadata version as it's coupled to the reserved state version. If a previous reserved state version exists, that one will be the version of the error. However, that can be any of the special versions <= 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ldematte changed as suggested

return true;
}

// Version 0 is special, snapshot restores will reset to 0.
if (reservedStateVersion.version() <= 0L) {
if (reservedStateVersion.version() <= ReservedStateMetadata.RESTORED_VERSION) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted this change to <= 0L, this better captures the intention of this: check that the new version is a regular positive one

@mosche
Copy link
Contributor Author

mosche commented May 7, 2024

@elasticmachine update branch

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

@mosche mosche merged commit 6e7afa0 into elastic:main May 7, 2024
15 checks passed
@mosche mosche deleted the reserved_cluster_state_versions branch May 7, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants