btlqql opened a new pull request, #4298:
URL: https://github.com/apache/rocketmq-dashboard/pull/4298
## What is the purpose of the change
Fixes #4297.
The active-alert-state lookup compares the collection scope's instance id
against
`rule.getInstanceId()` untrimmed, while the metric selector on the line
directly above is trimmed and
every rule that decides whether an alert fires trims too
(`NativeAlertRuleScopeMatcher`, `NativeAlertMetricCatalogService`,
`NativeAlertRuleTestService`). A
stored padded instance id therefore fires and writes `FIRING`/`ACKED` rows
that `findActive` cannot
see, so the alert disappears from the active/runtime view and
`NativeAlertProcessor.reconcileMissingActiveStates` can never resolve it.
## Brief changelog
-
`server/src/main/java/org/apache/rocketmq/studio/ops/alert/MybatisPlusAlertStateRepository.java`
- `findActive` compares
`StringUtils.trimWhitespace(rule.getInstanceId())`, matching the metric
filter beside it.
-
`server/src/main/java/org/apache/rocketmq/studio/ops/alert/NativeAlertProcessor.java`
- The reconcile candidate filter applies the same normalization, so the
padded rule is not dropped
before `findActive` is consulted.
-
`server/src/test/java/org/apache/rocketmq/studio/ops/alert/MybatisPlusAlertStateRepositoryTest.java`
- New `findsActiveStatesForRulesWithPaddedStoredInstanceIdsTest`,
mirroring the existing
padded-metric test.
## Verification
Red, before the fix (`mvn -o -f server/pom.xml test
-Dtest=MybatisPlusAlertStateRepositoryTest`):
```
[ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed:
2.141 s <<< FAILURE! -- in
org.apache.rocketmq.studio.ops.alert.MybatisPlusAlertStateRepositoryTest
Expected size: 1 but was: 0 in:
[ERROR]
MybatisPlusAlertStateRepositoryTest.findsActiveStatesForRulesWithPaddedStoredInstanceIdsTest:153
[ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0
[INFO] BUILD FAILURE
```
Green, after the fix
(`mvn -o -f server/pom.xml test
-Dtest=MybatisPlusAlertStateRepositoryTest,NativeAlertProcessorTest`):
```
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.094
s -- in org.apache.rocketmq.studio.ops.alert.MybatisPlusAlertStateRepositoryTest
[INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
0.751 s -- in org.apache.rocketmq.studio.ops.alert.NativeAlertProcessorTest
[INFO] Tests run: 24, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
## AI disclosure
Drafted with AI assistance (analysis, patch and test authoring); the red and
green Maven output above
was executed and observed locally on Windows, JDK 21.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]