Skip to content

Commit 3217538

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 3217538

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-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")

doc/03-Configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ do not need any manual adjustments.
6262
| max_placeholders_per_statement | **Optional.** Maximum number of placeholders Icinga DB is allowed to use for a single SQL statement. Defaults to `8192`. |
6363
| max_rows_per_transaction | **Optional.** Maximum number of rows Icinga DB is allowed to `SELECT`,`DELETE`,`UPDATE` or `INSERT` in a single transaction. Defaults to `8192`. |
6464
| wsrep_sync_wait | **Optional.** Enforce [Galera cluster](#galera-cluster) nodes to perform strict cluster-wide causality checks. Defaults to `7`. |
65+
66+
The [Icinga DB HA](05-Distributed-Setups.md#high-availability) feature uses its own database connection, separate
67+
from the other Icinga DB components, and this configuration cannot be altered by end users. Therefore, expect
68+
Icinga DB to establish `max_connections` + `1` database connections.
6569

6670
## Logging Configuration
6771

0 commit comments

Comments
 (0)