-
Notifications
You must be signed in to change notification settings - Fork 104
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
QueryIndex rollover when field mapping limit is reached #725
QueryIndex rollover when field mapping limit is reached #725
Conversation
Signed-off-by: Petar Dzepina <[email protected]>
…rce_index mappings Signed-off-by: Petar Dzepina <[email protected]>
alerting/src/main/kotlin/org/opensearch/alerting/BucketLevelMonitorRunner.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt
Show resolved
Hide resolved
alerting/src/main/kotlin/org/opensearch/alerting/model/MonitorMetadata.kt
Show resolved
Hide resolved
…hema; removed unused code Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #725 +/- ##
============================================
- Coverage 76.11% 75.30% -0.82%
Complexity 116 116
============================================
Files 124 125 +1
Lines 6618 6822 +204
Branches 982 1021 +39
============================================
+ Hits 5037 5137 +100
- Misses 1083 1154 +71
- Partials 498 531 +33
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
if (clusterService.state().metadata.hasIndex(ScheduledJob.DOC_LEVEL_QUERIES_INDEX)) { | ||
val acknowledgedResponse: AcknowledgedResponse = client.suspendUntil { | ||
admin().indices().delete(DeleteIndexRequest(ScheduledJob.DOC_LEVEL_QUERIES_INDEX)) | ||
} | ||
if (!acknowledgedResponse.isAcknowledged) { | ||
val errorMessage = "Deletion of old queryIndex [${ScheduledJob.DOC_LEVEL_QUERIES_INDEX}] index is not acknowledged!" | ||
log.error(errorMessage) | ||
throw AlertingException.wrap(OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR)) | ||
} | ||
} |
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.
Just to confirm, even when it gets deleted here, we don't care for the old data since we will recreate it anyways, right?
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.
Yes, it is checked if it exist and recreated if not, on every monitor update/execute API call and every monitor execution by job scheduler
// If we reached limit for total number of fields in mappings after rollover | ||
// it means that source index has more then (FIELD_LIMIT - 3) fields (every query index has 3 fields defined) |
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.
Can't we rollover multiple times?
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.
queryIndex already has 3 fields in mappings so when source_index has 997 fields or more, we couldn't succeed ever so we must abort
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.
but in any other case, yea, we can rollover
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.
Ahh I see. Can we add a TODO to support indices that have at least 997 fields by looking into breaking up the data amongst multiple rolled over indices?
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.
done!
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
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.
@petardz can we add an integration test for this scenario?
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
const val PROPERTIES = "properties" | ||
const val NESTED = "nested" | ||
const val TYPE = "type" | ||
const val INDEX_PATTERN_SUFFIX = "-000001" |
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 the number getting incremented during rollovers? If so, where?
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.
It is done by _rollover core's API here
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.
Thanks
Assert.assertTrue(alerts.size == 1) | ||
|
||
// Both monitors used same queryIndex. Since source index has close to limit amount of fields in mappings, | ||
// we expect that creation of second monitor would rollover queryIndex |
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.
Wait is the expectation that the queryIndex
is rolled over or not? It is not getting rolled over here.
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.
This comment was incorrect. I fixed it with new commit and added few more in other tests
Assert.assertTrue(alerts.size == 2) | ||
} | ||
|
||
fun `test queryIndex bwc`() { |
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.
Update name to test queryIndex bwc when index was not an alias
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.
done!
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
xContentRegistry, | ||
settings | ||
) | ||
|
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.
are these objects needed? looks like lot of old alerting
code is refactored into these classes?
this.settings = settings | ||
} | ||
|
||
suspend fun newInstance(monitor: Monitor, createWithRunContext: Boolean): MonitorMetadata { |
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.
this is an unused method?
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-725-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 6f487462862d92def1334599c1d0aaad5201a270
# Push it to GitHub
git push --set-upstream origin backport/backport-725-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
Signed-off-by: Petar Dzepina <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.3 2.3
# Navigate to the new working tree
cd .worktrees/backport-2.3
# Create a new branch
git switch --create backport/backport-725-to-2.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 6f487462862d92def1334599c1d0aaad5201a270
# Push it to GitHub
git push --set-upstream origin backport/backport-725-to-2.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.3 Then, create a pull request where the |
Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 6f48746)
Signed-off-by: Petar Dzepina [email protected]
Issue #, if available:
Description of changes:
Added handling of situation when queryIndex has more fields in mapping then set limit(default 1000).
queryIndex is now alias instead of concrete index
Index pattern is computed like this: queryIndex + "-1"
We keep mapping of source_index+monitorId --> concreteQueryIndex in map inside Monitor object.
CheckList:
[ ] Commits are signed per the DCO using --signoff
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.