Skip to content

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Sep 3, 2025

When new cluster settings are applied, consumers watchings are notified. The consumer should see the latest value at the time of initializing a watch. However, only the node settings were ever used in finding the value to initialize the consumer. This commit fixes the consumer to use the value from latest applied if it exists.

closes #133701

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
@rjernst rjernst requested a review from a team as a code owner September 3, 2025 22:00
@rjernst rjernst added >bug :Core/Infra/Settings Settings infrastructure and APIs auto-backport Automatically create backport pull requests when merged v9.1.4 v9.0.7 v8.18.7 v8.19.4 labels Sep 3, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Sep 3, 2025
@elasticsearchmachine
Copy link
Collaborator

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

assert setting.getProperties().contains(Setting.Property.NodeScope) : "Can only watch node settings";
consumer.accept(setting.get(settings));

// this mimics the combined settings of last applied and node settings, without building a new settings object
Copy link
Contributor

Choose a reason for hiding this comment

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

With this comment I understand you are trying to avoid doing
Settings.builder().put(this.settings).put(this.lastSettingsApplied).build() like in other functions, correct?

Is there an advantage? Is it correct? (is lastSettingsApplied always a superset of settings?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Building a combined Settings object is heavyweight. It requires combing the internal maps that each Settings object contains.

If the latter settings object contains a setting we are looking for, it would have overridden the value when combined, so looking at the latter first should mimic the combined behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Building a combined Settings object is heavyweight. It requires combing the internal maps that each Settings object contains.

I understand that, but I was wondering if it really matters in this case - I might be mistaken, but this is an initialization method, so probably it's not on a hot path.

As long as it's correct I like the optimization though.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is an initialization method

While true, it's also called for every setting that is watched, currently 43 uses. Seems silly to reconstruct the same settings object 43 times (but also not worth the complexity to cache it in a threadsafe way).

@rjernst rjernst enabled auto-merge (squash) September 8, 2025 16:49
@rjernst rjernst merged commit d5e0334 into elastic:main Sep 8, 2025
34 checks passed
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 8, 2025
)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 8, 2025
)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 8, 2025
)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.1
9.0
8.18
8.19

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 8, 2025
)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
elasticsearchmachine pushed a commit that referenced this pull request Sep 8, 2025
…134315)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes #133701
elasticsearchmachine pushed a commit that referenced this pull request Sep 8, 2025
…134314)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes #133701
elasticsearchmachine pushed a commit that referenced this pull request Sep 8, 2025
…134313)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes #133701
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Sep 9, 2025
)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
elasticsearchmachine pushed a commit that referenced this pull request Sep 10, 2025
…134316)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes #133701
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 11, 2025
) (elastic#134316)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 19, 2025
) (elastic#134316)

When new cluster settings are applied, consumers watchings are notified.
The consumer should see the latest value at the time of initializing a
watch. However, only the node settings were ever used in finding the
value to initialize the consumer. This commit fixes the consumer to use
the value from latest applied if it exists.

closes elastic#133701
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 >bug :Core/Infra/Settings Settings infrastructure and APIs Team:Core/Infra Meta label for core/infra team v8.18.7 v8.19.4 v9.0.7 v9.1.4 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings initializeAndWatch can miss settings changes

3 participants