Skip to content

Commit 4062f86

Browse files
committed
HA: Limit max open database connections to 1
Previously, the HA feature was allowed to open `max_connections` database connection in parallel to other Icinga DB components. Meaning, Icinga DB wasn't limited to the configured `max_connections`, but effectively to `2 * max_connections`. Additionally, this masked a serious bug in the `HA#realize()` method, where we start a new transaction after each retry without rolling back in case of an error, leading to connections not being released before exceeding the ctx deadline.
1 parent 3484476 commit 4062f86

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

cmd/icingadb/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func run() int {
113113
logger.Fatalf("%+v", errors.Wrap(err, "can't create database connection pool from config"))
114114
}
115115
defer func() { _ = db.Close() }()
116+
db.SetMaxOpenConns(1)
116117
ha = icingadb.NewHA(ctx, db, heartbeat, logs.GetChildLogger("high-availability"))
117118

118119
telemetryLogger := logs.GetChildLogger("telemetry")

0 commit comments

Comments
 (0)