Skip to content

Commit fc87369

Browse files
oxziyhabteab
andcommitted
HA: Use Transaction for each query
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 <yonas.habteab@icinga.com>
1 parent accf30b commit fc87369

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/icingadb/ha.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func (h *HA) realize(
392392
// Insert the environment after each heartbeat takeover if it does not already exist in the database
393393
// as the environment may have changed, although this is likely to happen very rarely.
394394
stmt, _ = h.db.BuildInsertIgnoreStmt(h.environment)
395-
if _, err := h.db.NamedExecContext(ctx, stmt, h.environment); err != nil {
395+
if _, err := tx.NamedExecContext(ctx, stmt, h.environment); err != nil {
396396
return database.CantPerformQuery(err, stmt)
397397
}
398398
}

0 commit comments

Comments
 (0)