Skip to content

Commit

Permalink
Fix alerts duplication in HA cluster mode
Browse files Browse the repository at this point in the history
Signed-off-by: nip <[email protected]>
  • Loading branch information
nip-was-here committed Dec 5, 2024
1 parent 0f65e8f commit b9f7a85
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions nflog/nflog.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,19 @@ func (l *Log) Merge(b []byte) error {
defer l.mtx.Unlock()
now := l.now()

var needsBroadcast = false
for _, e := range st {
if merged := l.st.merge(e, now); merged && !cluster.OversizedMessage(b) {
// If this is the first we've seen the message and it's
// not oversized, gossip it to other nodes. We don't
// propagate oversized messages because they're sent to
// all nodes already.
l.broadcast(b)
l.metrics.propagatedMessagesTotal.Inc()
l.logger.Debug("gossiping new entry", "entry", e)
if merged := l.st.merge(e, now); merged {
// If this is the first we've seen the message, gossip state to other nodes.
needsBroadcast = true
}
}

if needsBroadcast {
l.broadcast(b)
l.metrics.propagatedMessagesTotal.Inc()
l.logger.Debug("gossiping new entry", "entry", e)
}
return nil
}

Expand Down

0 comments on commit b9f7a85

Please sign in to comment.