Skip to content

Conversation

@masseyke
Copy link
Member

@masseyke masseyke commented Dec 2, 2025

The get data streams API needs the data stream's settings in order to get information about ILM and the index mode. It calls MetadataDataStreamsService::getEffectiveSettings to do this, which is correct. However, that method is fairly expensive because it calls getEffectiveMappings so that it can call addSettingsFromIndexSettingProviders with the correct mappings. We don't need any of the information from these index settings providers for ILM or the index mode. Since the get data streams API can be called for all data streams, we call this slow method hundreds or thousands of times, and the API can take so long to return that kibana gives up on it.
This PR removes the call to getEffectiveSettings, and instead just gathers the settings from the template, along with data stream settings overrides.
This was caused by #137407

@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Dec 2, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, I left one comment, thanks for fixing this.

template,
state.metadata().componentTemplates()
);
final Settings settings = templateSettings.merge(dataStream.getSettings());
Copy link
Member

Choose a reason for hiding this comment

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

I think this makes sense. Can we also add something like:

assert settings.equals(metadataDataStreamsSettingsService.getEffectiveSettings(state.metadata(), dataStream)) : "these should always match etc etc";

after this line, so that if we ever encountered a situation where a provider changed the settings, then we would fail tests? That way we only pay the cost when asserts are enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that that assertion would work, b/c the providers do change some of the settings.

Comment on lines 286 to 287
* settings so that we can get some ilm information and the index mode, neither of which come from additional settings
* providers.
Copy link
Contributor

Choose a reason for hiding this comment

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

the index mode, neither of which come from additional settings
Comment providers.

I don't think that is true; LogsdbIndexModeSettingsProvider seems to supply an index mode:

additionalSettings.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB.getName());

Or am I misreading something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good catch. That complicates things.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking then that I'll still call getEffectiveSettings, but a new variant that lets you skip merging all the mappings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, actually that next line that calls resolveMode actually applies all of the additional settings providers and we get the correct mode anyway. I'll add a test that shows that.

@masseyke masseyke added the auto-backport Automatically create backport pull requests when merged label Dec 3, 2025
@masseyke masseyke merged commit a0289db into elastic:main Dec 3, 2025
34 checks passed
@masseyke masseyke deleted the get-data-streams-performance branch December 3, 2025 20:11
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.2

masseyke added a commit to masseyke/elasticsearch that referenced this pull request Dec 3, 2025
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 :Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team v9.2.3 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants