-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use ClusterStateRequest with index pattern when searching for expired local indices #262
Conversation
… local indices Signed-off-by: David Zane <davizane@amazon.com>
I think you also need to make the same changes here: query-insights/src/main/java/org/opensearch/plugin/insights/core/service/QueryInsightsService.java Line 622 in 5ef5437
|
Another improvement we can do is, on this line query-insights/src/main/java/org/opensearch/plugin/insights/core/service/TopQueriesService.java Line 555 in 5ef5437
parts[2].matches("\\d{5}"); , we can call this function to verify if the hash is correct as well.query-insights/src/main/java/org/opensearch/plugin/insights/core/utils/ExporterReaderUtils.java Line 29 in 5ef5437
Let me know if you want to include it in this PR as well, if not I'll probably do it in another PR. |
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest().clear() | ||
.indices(TOP_QUERIES_INDEX_PATTERN_GLOB) | ||
.metadata(true) | ||
.local(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the java doc, the local parameter is defined as: "Return local information, do not retrieve the state from cluster-manager node (default: false).".
using data from cluster manager node requires one extra network hop, it will also have higher latency, but the benifit is we will always have the most accurate info..
But in our case, the absolute consistency is not critical neither.. I'm fine with either approach, just leave the info here in case anyone has other opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is cluster state equivalent on cluster manager vs non cluster manager nodes? I am wondering if local node info can be incomplete or stale.
I will update |
Signed-off-by: David Zane <davizane@amazon.com>
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/query-insights/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/query-insights/backport-2.x
# Create a new branch
git switch --create backport/backport-262-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 efb871cede2fbb23d5a5c0a0ef9f3c46172743eb
# Push it to GitHub
git push --set-upstream origin backport/backport-262-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/query-insights/backport-2.x Then, create a pull request where the |
… local indices (opensearch-project#262) * Use ClusterStateRequest with index pattern when searching for expired local indices Signed-off-by: David Zane <davizane@amazon.com> * Update deleteAllTopNIndices Signed-off-by: David Zane <davizane@amazon.com> --------- Signed-off-by: David Zane <davizane@amazon.com> Signed-off-by: Chenyang Ji <cyji@amazon.com>
… local indices (#262) (#263) * Use ClusterStateRequest with index pattern when searching for expired local indices * Update deleteAllTopNIndices --------- Signed-off-by: David Zane <davizane@amazon.com> Signed-off-by: Chenyang Ji <cyji@amazon.com> Co-authored-by: David Zane <38449481+dzane17@users.noreply.github.com>
… local indices (#262) (#263) * Use ClusterStateRequest with index pattern when searching for expired local indices * Update deleteAllTopNIndices --------- Signed-off-by: David Zane <davizane@amazon.com> Signed-off-by: Chenyang Ji <cyji@amazon.com> Co-authored-by: David Zane <38449481+dzane17@users.noreply.github.com> (cherry picked from commit 1c102c4) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… local indices (#262) (#263) (#264) * Use ClusterStateRequest with index pattern when searching for expired local indices * Update deleteAllTopNIndices --------- (cherry picked from commit 1c102c4) Signed-off-by: David Zane <davizane@amazon.com> Signed-off-by: Chenyang Ji <cyji@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: David Zane <38449481+dzane17@users.noreply.github.com>
Description
Currently we scan a list of all indices on a domain when looking for expired Top N local indices. This causes extra computation on domains with many indices & greater possibility of mistake.
This PR reduces risk by limiting the indices fetched to those that match the
top_queries-*
name pattern. It then applies the existing protocol, which includes a stricter check for the index name (top_queries-<date>-<5 digits>
), as well as validation of creation time and metadata before any deletions are performed.Testing
delete_after_days
setting to trigger expired index scan + deletiontop_queries-*
pattern were considered for deletionIssues Resolved
Resolves #261
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.