Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary\nThis PR fix(alert): keep evaluation state on cosmetic rule edits and toggles modifies 2 files (+58 -8).\n\n### Findings\n- [Info] Long string literal: consider extracting to a constant\n\nPlease review the findings above.\n\n---\nAutomated review by "github-manager-bot"
lizhimins
left a comment
There was a problem hiding this comment.
Half of this is a real fix and half introduces a new risk; please split it.
The real fix: AlertService.updateRule (:207) calls deleteByRuleId unconditionally, so renaming a rule or editing its description clears FIRING/ACK state and AlertStateMachine.advanceHit (:71-87) re-fires from scratch. Making that cleanup conditional on the fingerprint actually changing is right, and the three new tests plus the six revised deleteByRuleId assertions check out.
The new risk: the patch also drops the cleanup on toggle, and nothing converges the state of a disabled rule — MybatisPlusAlertStateRepository.java:105 and NativeAlertProcessor.java:104 both filter on enabled. After a rule is disabled and re-enabled, a stale FIRING row stops advanceHit from emitting a new FIRING event, which can swallow a genuinely new incident.
Please keep the fingerprint condition and either retain the disable-time cleanup or add convergence for disabled rules.
Clear FIRING/ACK only when the semantic fingerprint changes. Disabling a rule still clears state so a later re-enable cannot swallow a new incident behind a stale FIRING row. Fixes apache#4326 Signed-off-by: halaxy <63827956+89799969@users.noreply.github.com>
e3995cc to
a42d274
Compare
|
Split per review:
|
|
@lizhimins Following up - fingerprint-gated update cleanup kept; disable-time state cleanup restored for single and bulk toggle ( |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Reviewed PR #4327: fix(alert): keep evaluation state on cosmetic rule edits and toggles
The changes look reasonable. No critical issues identified.
Observations
- 2 files changed
- Test coverage: test files included ✓
Automated review by github-manager-bot
Fixes #4326
Problem
Every successful
updateRuleandtoggleRulecall unconditionally runsalertStateRepository.deleteByRuleId(id). That wipes the live FIRING / ACK / PENDING episode even when the evaluation identity did not change.Consequences:
AlertRuleSemanticFingerprintalready encodes the fields that decide firing (metric, threshold, operator, duration, scope, samples, …) and is used for duplicate detection.Fix
updateRuleloads the existing rule and deletes state only when the semantic fingerprint changes.toggleRule/bulkToggleRulesno longer delete state (enable/disable is not an evaluation change).Testing
AlertServiceTest(79 tests), including:updatingRuleNameWithoutChangingEvaluationConditionsKeepsStateTestupdatingRuleThresholdResetsEvaluationStateTesttogglingRuleKeepsEvaluationStateTestupdatingRuleShouldResetItsPreviousEvaluationStateTest(existing, still passes when no prior rule row)Local run: Temurin 21.0.12.1,
mvn -Dtest=AlertServiceTest test