Skip to content

Commit

Permalink
HA: Use Transaction for each query
Browse files Browse the repository at this point in the history
During #800, the commit dd0ca8f inlined
the HA.insertEnvironment method into the retryable realization function.
However, while doing so, I forgot to change the query execution context
from h.db to tx. This resulted in an error when being used together with
a single database connection, as introduced in #828.

Co-Authored-By: Yonas Habteab <[email protected]>
  • Loading branch information
oxzi and yhabteab committed Dec 17, 2024
1 parent accf30b commit fc87369
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/icingadb/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (h *HA) realize(
// Insert the environment after each heartbeat takeover if it does not already exist in the database
// as the environment may have changed, although this is likely to happen very rarely.
stmt, _ = h.db.BuildInsertIgnoreStmt(h.environment)
if _, err := h.db.NamedExecContext(ctx, stmt, h.environment); err != nil {
if _, err := tx.NamedExecContext(ctx, stmt, h.environment); err != nil {
return database.CantPerformQuery(err, stmt)
}
}
Expand Down

0 comments on commit fc87369

Please sign in to comment.