Skip to content

Commit

Permalink
HA State: ensure not this and another instance can be responsible
Browse files Browse the repository at this point in the history
In theory, this should not happen. This assumption is based on the trust
in the database transaction performing the HA realization logic.
However, one debugged log let one assume that this happened anyway.

This change mostly signals an error while also explicitly giving up the
HA state. Doing so should at least alarm a person reading the logs.
  • Loading branch information
oxzi committed Oct 28, 2024
1 parent 1d04ffe commit a38491a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/icingadb/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ func (h *HA) realize(

h.signalTakeover(takeover)
} else if otherResponsible {
if state := h.state.Load(); state.responsible {
h.logger.Error("Other instance is responsible while this node itself is responsible, dropping responsibility")
h.signalHandover("other instance is responsible as well")
// h.signalHandover will update h.state
}
if state := h.state.Load(); !state.otherResponsible {
// Dereference pointer to create a copy of the value it points to.
// Ensures that any modifications do not directly affect the original data unless explicitly stored back.
Expand Down

0 comments on commit a38491a

Please sign in to comment.