Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Nov 12, 2025

When file settings tests look for changes in cluster state to assert application of changes they do so by adding a cluster state listener. But if there are no more cluster state updates after the listener is added the test will never see the initial state of file settings. This commit ensures the current cluster state is seen in that case.

closes #36454

When file settings tests look for changes in cluster state to assert
application of changes they do so by adding a cluster state listener.
But if there are no more cluster state updates after the listener is
added the test will never see the initial state of file settings. This
commit ensures the current cluster state is seen in that case.

closes elastic#36454
@rjernst rjernst added >test Issues or PRs that are addressing/adding tests :Core/Infra/Settings Settings infrastructure and APIs auto-backport Automatically create backport pull requests when merged branch:9.2 branch:9.1 branch:8.19 labels Nov 12, 2025
@rjernst rjernst requested a review from prdoyle November 12, 2025 14:24
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@prdoyle prdoyle left a comment

Choose a reason for hiding this comment

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

One more race condition down.

if (reservedState != null && reservedState.version() == fileSettingsVersion) {
clusterService.removeListener(this);
metadataVersion.set(event.state().metadata().version());
metadataVersion.set(clusterState.metadata().version());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand this correctly? If the reserved state version is the one we're expecting, we infer that the metadata version must also be the one we're expecting, on the assumption that the latest metadata update was the one that updated the reserved state. This seems ok in these particular tests where there are very few metadata updates, even though it wouldn't be correct in general.

Am I close?

Did you manage to induce this logic path with sleeps in the tests that call this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't assert anything about the metadata version, this captures the metadata version once we see the file settings version we expect.

And yes I reproduced with a sleep just before creating the state listener.

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 :Core/Infra/Settings Settings infrastructure and APIs Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.19.8 v9.1.8 v9.2.2 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants