Repository navigation
fix: correct inverted condition in DocLevelMonitorQueries causing query index churn - #2154
Conversation
55734fa to
289f661
Compare
|
@thecodingshrimp same comment here as the other PR. Can we add a test for this? |
PR Reviewer Guide 🔍(Review updated until commit 86eadb7)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Persistent review updated to latest commit 9394ff7 |
…ry index churn (opensearch-project#2153) Signed-off-by: thecodingshrimp <leonard.stutzer@sap.com>
…-project#2153) Signed-off-by: thecodingshrimp <leonard.stutzer@sap.com>
…eries (opensearch-project#2153) - Clarify updateQueryIndexMappings comment (churn fix is primary, alias-persistence is secondary) - Open class and key methods for test isolation; document extension-point intent - Add log.warn when updateSettings is not acknowledged - Add lastPutConcreteQueryIndex assertions across all happy-path tests - Add tests: null+flag=false resolves; alias with no write index; field-limit rollover; non-field-limit exception Signed-off-by: thecodingshrimp <leonard.stutzer@sap.com>
9394ff7 to
86eadb7
Compare
|
Persistent review updated to latest commit 86eadb7 |
@cwperks added some tests |
Summary
Fixes #2153
The condition in
DocLevelMonitorQueries.updateQueryIndexMappingsthat decides when to re-fetch the write index from the query index alias was inverted (!=instead of==). This caused the re-fetch path to fire on every monitor execution rather than only in the backwards-compatibility case it was designed to handle.Root Cause
monitorMetadata.sourceToQueryIndexMappingstores the concrete backing index name (e.g..opensearch-sap-pre-packaged-rules-queries-000001) after the first successful lookup. The condition was intended to re-resolve the alias only when the stored value is the alias name itself — a legacy situation where the metadata was written before this logic existed.With
!=, the condition evaluates totrueon every subsequent run because the stored concrete index name is always different from the alias name. This triggersgetWriteIndexNameForAliasand a metadata rewrite on every run, which cascades into a delete+recreate of the backing query index, generating 6–10MergeSchedulerConfiglog lines per node per cycle.With
==, the condition correctly fires only when the alias name itself is stored, which is the backwards-compat path it was designed for.Fix
The comment block was also updated to document the correct invariant.
Impact
At scale (3 master nodes, many detectors), the broken condition produced 23,000+
MergeSchedulerConfiglog lines per minute. This fix eliminates that churn.Related
This bug is amplified by a separate issue in
opensearch-project/security-analyticswherechained_findingsmonitors are created withdeleteQueryIndexInEveryRun=true, activating the broken code path on every detector run. Both fixes are needed to fully eliminate the log storm. The security-analytics fix prevents the flag from being set unnecessarily; this fix corrects the inverted logic that acts on it.