Skip to content

fix(alerter): fall back to default repeat interval when group rule was deleted - #4361

Open
zjncs wants to merge 1 commit into
apache:masterfrom
zjncs:fix-alert-group-rule-deleted-npe
Open

zjncs wants to merge 1 commit into
apache:masterfrom
zjncs:fix-alert-group-rule-deleted-npe

Conversation

@zjncs

@zjncs zjncs commented Sep 4, 2026

Copy link
Copy Markdown

What's changed

When a converge rule is deleted, renamed or disabled while its group cache still holds firing alerts, AlarmGroupReduce.sendGroupAlert looks up the rule and dereferences it without a null check (hertzbeat-alerter/.../AlarmGroupReduce.java:294):

AlertGroupConverge ruleConfig = groupDefines.get(cache.getGroupDefineName());
long repeatInterval = ruleConfig.getRepeatInterval() != null ...

refreshGroupDefines clears and reloads only enabled rules (called on every rule add/update/delete from AlertGroupConvergeServiceImpl), but entries in groupCacheMap keep their groupDefineName, so the lookup returns null for an orphaned group.

Impact is worse than a one-off NPE: runCheckAndSendGroups iterates groupCacheMap.forEach and the NPE aborts the whole iteration each cycle (caught at the loop level), so every group ordered after the orphaned one stops receiving converged alerts, permanently, on every 1-second check cycle until restart.

The sibling method shouldSendGroup in the same file already null-checks the identical lookup for groupWait/groupInterval and falls back to defaults; this PR applies the same fallback to repeatInterval.

Checklist

  • I have read the Contributing Guidelines.
  • I have added a unit test for the change (whenRuleDeleted_firingGroupCacheMustStillBeDispatched in AlarmGroupReduceTest).
  • All tests pass locally (mvn -pl hertzbeat-alerter -am test: 474 tests, 0 failures).

Verification

  • fail-before: the new test fails on master — the dispatch is aborted by
    java.lang.NullPointerException: Cannot invoke "AlertGroupConverge.getRepeatInterval()" because "ruleConfig" is null at AlarmGroupReduce.java:294, logged by runCheckAndSendGroups' catch, and inhibitAlarm is never invoked for the orphaned group
  • pass-after: the orphaned firing group is dispatched with the default repeat interval; all 7 AlarmGroupReduceTest tests and the full alerter module suite pass (474 tests, 0 failures, 2 pre-existing skips)

AI assistance disclosure: the bug analysis, fix and test in this PR were prepared with the help of an AI coding agent, and were verified locally by the author as described above.

…s deleted

When a converge rule is deleted, renamed or disabled while its group
cache still holds firing alerts, sendGroupAlert looked up the rule and
dereferenced it without a null check. The NPE aborted the
groupCacheMap iteration in runCheckAndSendGroups every check cycle, so
every group ordered after the orphaned one stopped receiving converged
alerts until the process restarted.

Fall back to DEFAULT_REPEAT_INTERVAL, mirroring the null handling that
shouldSendGroup already applies for the group wait and group interval.

Signed-off-by: zjncs <18910855655@163.com>
@zjncs
zjncs marked this pull request as ready for review September 4, 2026 12:13
Copilot AI lite review requested due to automatic review settings September 4, 2026 12:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants