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

Fix to load indices status in batches so that the URL used to call OpenSearch does not exceed maximum length #21208

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

janheise
Copy link
Contributor

@janheise janheise commented Dec 17, 2024

Description

Prior to this PR, a call to getIndicesBlocksStatus() would exceed to URL maximum of 4096 bytes if the number of indices would be large. This PR mitigates the problem by getting the status in batches and merges the result. I

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copy link
Member

@dennisoelkers dennisoelkers left a comment

Choose a reason for hiding this comment

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

Thanks for this! Some suggestions for improvement:

  1. We should try to use an endpoint where we can get results in a single response to avoid multiple round-trips. We could use /_settings/index.blocks.read,index.blocks.write,index.blocks.metadata for example.
  2. We could do this, when indices.stream().collect(joining(",")).length > threshold
  3. Should we also implement this for the ES7 module?

Copy link
Member

@dennisoelkers dennisoelkers left a comment

Choose a reason for hiding this comment

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

Some inline questions.

final GetSettingsResponse settingsResponse = c.indices().getSettings(getSettingsRequest, requestOptions);
return BlockSettingsParser.parseBlockSettings(settingsResponse);
});
if(String.join(",", indices).length() > MAX_INDICES_URL_LENGTH) {
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 we should safe some buffer here, as there will also be the path + additional query parameters (+ potential url encoding overhead?). Let's play it safe and reduce MAX_INDICES_URL_LENGTH to 2500?

});
if(String.join(",", indices).length() > MAX_INDICES_URL_LENGTH) {
final GetSettingsRequest getSettingsRequest = new GetSettingsRequest()
.indicesOptions(IndicesOptions.fromOptions(false, true, true, true))
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 use .names("index.blocks.read", ...) to get only the blocks here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants