Skip to content

Conversation

@dzane17
Copy link
Member

@dzane17 dzane17 commented Oct 20, 2025

Description

Remove logic that deletes all Query Insights indices when exporter type setting is changed

Issues Resolved

Resolves #453

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: David Zane <davizane@amazon.com>
@dzane17 dzane17 marked this pull request as ready for review October 20, 2025 23:50
@dzane17 dzane17 changed the title Don't delete all local indices on exporter type change Persist local indices on exporter type change Oct 20, 2025
* @param client OpenSearch Client
* @param localIndexExporter the exporter to handle the local index operations
*/
void deleteAllTopNIndices(final Client client, final LocalIndexExporter localIndexExporter) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should add an API endpoint to do this?

Copy link
Member Author

@dzane17 dzane17 Oct 21, 2025

Choose a reason for hiding this comment

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

No, admins can delete indices manually I believe and retention policy will still apply

Copy link
Member

Choose a reason for hiding this comment

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

makes sense.

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 one caveat here is, if there are issues with local index exporters, we won't have a quick solution to solve it. like, for the local index reader performance issue we encountered this year, we can simply disable this setting to remove all local index.

If any similar unknown issue happens later, we will need to delete user's indices manually (without the validation logic in our code), or wait for 1 day until the retention job kicks in.

That's the reason I feel it's better to have an API to delete all indices with correct validation logic would make sense. Another alternative is to lower the min value of the delete_after setting to say 1 hour. but the deletion logic will be more complicated since we will need to delete the documents instead of the indices.

@ansjcy
Copy link
Member

ansjcy commented Oct 24, 2025

Let's also create a documentation PR for this, we missed adding the expectation for disabling the local index (i.e. warning: local index will be deleted after you disable local index). We should call this out now in the doc: your index will not be deleted, if you need to delete, do it manually.

assertTrue(fieldTypeCacheStats.containsKey(MISS_COUNT));
}

public void testDeleteAllTopNIndices() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

instead of removing the tests, we should have tests to validate that the local index "will not be deleted" after disabling.

* @param client OpenSearch Client
* @param localIndexExporter the exporter to handle the local index operations
*/
void deleteAllTopNIndices(final Client client, final LocalIndexExporter localIndexExporter) {
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 one caveat here is, if there are issues with local index exporters, we won't have a quick solution to solve it. like, for the local index reader performance issue we encountered this year, we can simply disable this setting to remove all local index.

If any similar unknown issue happens later, we will need to delete user's indices manually (without the validation logic in our code), or wait for 1 day until the retention job kicks in.

That's the reason I feel it's better to have an API to delete all indices with correct validation logic would make sense. Another alternative is to lower the min value of the delete_after setting to say 1 hour. but the deletion logic will be more complicated since we will need to delete the documents instead of the indices.

@ansjcy
Copy link
Member

ansjcy commented Oct 24, 2025

I have some deeper concerns on the retention policy behavior after this change.

  1. If we disable local index exporter, that delete_after job will not delete the expired indices now because the related logic will only run if local index exporter is enabled
    if (topQueriesExporter != null && topQueriesExporter.getClass() == LocalIndexExporter.class) {
    , these indices will become orphaned forever.
  2. If "enable local index" -> "disable all features" , because of this check , the old indices will also remain there forever.

Let's think about even more scenarios: like

  • local_index -> disable all features -> reenable with local index
  • local_index -> disable all -> reenable with none
    ...

IMO we should always enforce the retention job, regardless whether features are enabled, or what type of exporter is enabled. we can also consider adding "none" to delete after , so that people can also disable this retention job.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Query Insights exporter delete the local saved indices if customer disables the exporter

2 participants