icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Fix a race condition in NotificationComponent leading to duplicate notification

Open jschmidt-icinga opened this issue 1 year ago • 0 comments

Problem

The race is between NotificationTimerHandler, which sends a reminder notification after a certain inverval during problem states and SendNotificationsHandler which sends out the notifications on state changes.

When the timer handler runs just before a state change triggers a notification, the timer handler might pick up that state-change before the send notification handler can set its no_more_notifications flag. In that case a "reminder" notification will be sent out before the initial one, and despite interval = 0 on the notification object.

Solution?

The trivial solution here is to never attempt to send a reminder if interval <= 0 and not wait for the no_more_notifications flag. I'm not entirely sure if there are any negative consequences to that because I don't understand what this flag is even supposed to do. It seems it only gets set in case of interval <= 0 and only ever used in this one place. I can think of many valid reasons to want to turn off reminders under certain conditions for a while, but this doesn't even do that, since it was an &&-condition, not an || (which it is in the current state of this PR).

Fixes #10623.

jschmidt-icinga avatar Nov 07 '25 15:11 jschmidt-icinga