Skip to content

Restore API: Fix file settings handling#137585

Merged
mamazzol merged 11 commits intoelastic:mainfrom
mamazzol:empty-reserved-state
Nov 11, 2025
Merged

Restore API: Fix file settings handling#137585
mamazzol merged 11 commits intoelastic:mainfrom
mamazzol:empty-reserved-state

Conversation

@mamazzol
Copy link
Contributor

@mamazzol mamazzol commented Nov 4, 2025

When restoring a snapshot including global state, do not remove the reserved state, but initialise an empty one. This prevents the readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing reserved state settings and file settings.

Fixes #122429

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes elastic#122429
@mamazzol mamazzol added the :Core/Infra/Settings Settings infrastructure and APIs label Nov 4, 2025
@elasticsearchmachine elasticsearchmachine added v9.3.0 Team:Core/Infra Meta label for core/infra team labels Nov 4, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@mamazzol mamazzol added the >bug label Nov 4, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @mamazzol, I've created a changelog YAML for you.

@mamazzol mamazzol requested a review from a team November 7, 2025 09:50
.metadata()
.reservedStateMetadata()
.get(FileSettingsService.NAMESPACE);
assertThat(reservedState, notNullValue());
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 any possibility of a race condition here? Since reserved state is process async, is there a possibility that the "clearing" hasn't been finished before we assert on it here?

Copy link
Contributor

@prdoyle prdoyle Nov 7, 2025

Choose a reason for hiding this comment

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

<sigh> We're overdue for a straightforward, sanctioned way to wait for various things to be done. Eventual consistency sucks for testing (and for users, but that's another topic). I suppose a callback on a CountdownLatch or similar could do it, though it somewhat sucks to have to rediscover this for each test.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Also the CountdownLatch technique only works if your callback is only called at the appropriate time. Since "exactly once" semantics are sometimes hard to implement in systems, they often settle for "at least once", and then the callback can occasionally have extra bonus calls, which can make the CountdownLatch technique flaky in various ways.)

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 tried adding the CountdownLatch technique present in other parts of this test class, but I wasn't able to find the sweet spot to make it work. The fact that the file processing happens right at startup means I cannot bind the listener before or after the restart as that is too early or too late.

I added the assertBusy as a way of handling it but I am happy to evaluate different ways if this is not good enough.

@mamazzol mamazzol merged commit d7d002b into elastic:main Nov 11, 2025
34 checks passed
@mamazzol mamazzol deleted the empty-reserved-state branch November 11, 2025 09:24
@elasticsearchmachine
Copy link
Collaborator

elasticsearchmachine commented Nov 11, 2025

💔 Backport failed

Status Branch Result
9.2
8.19 Commit could not be cherrypicked due to conflicts
9.1

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 137585

mamazzol added a commit to mamazzol/elasticsearch that referenced this pull request Nov 11, 2025
* Restore API: Fix file settings handling

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes elastic#122429
mamazzol added a commit to mamazzol/elasticsearch that referenced this pull request Nov 11, 2025
* Restore API: Fix file settings handling

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes elastic#122429
@mamazzol
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request Nov 12, 2025
* Restore API: Fix file settings handling

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes #122429
elasticsearchmachine pushed a commit that referenced this pull request Nov 12, 2025
* Restore API: Fix file settings handling

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes #122429
mamazzol added a commit that referenced this pull request Nov 14, 2025
* Restore API: Fix file settings handling

When restoring a snapshot including global state, do not remove the
reserved state, but initialise an empty one. This prevents the
readiness service from crashing.
Also, initialising an empty state now correctly removes pre-existing
reserved state settings and file settings.

Fixes #122429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >bug :Core/Infra/Settings Settings infrastructure and APIs Team:Core/Infra Meta label for core/infra team v8.19.8 v9.1.8 v9.2.2 v9.3.0

4 participants