Skip to content

Commit

Permalink
HA: Limit max open database connections to 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yhabteab committed Oct 24, 2024
1 parent 3484476 commit 4062f86
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cmd/icingadb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func run() int {
logger.Fatalf("%+v", errors.Wrap(err, "can't create database connection pool from config"))
}
defer func() { _ = db.Close() }()
db.SetMaxOpenConns(1)
ha = icingadb.NewHA(ctx, db, heartbeat, logs.GetChildLogger("high-availability"))

telemetryLogger := logs.GetChildLogger("telemetry")
Expand Down

0 comments on commit 4062f86

Please sign in to comment.