Skip to content

Commit 528b7a1

Browse files
committed
fix(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 never being released.
1 parent 3484476 commit 528b7a1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/icingadb/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func run() int {
109109
heartbeat = icingaredis.NewHeartbeat(ctx, rc, logs.GetChildLogger("heartbeat"))
110110

111111
db, err := cmd.Database(logs.GetChildLogger("database"))
112+
db.SetMaxOpenConns(1)
112113
if err != nil {
113114
logger.Fatalf("%+v", errors.Wrap(err, "can't create database connection pool from config"))
114115
}

doc/03-Configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ do not need any manual adjustments.
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`. |
6565

66+
!!! info
67+
68+
The [Icinga DB HA](05-Distributed-Setups.md#high-availability) feature uses its own database connection, separate
69+
from the other Icinga DB components, and this configuration cannot be altered by end users. Therefore, expect
70+
Icinga DB to establish `max_connections` + `1` database connections.
71+
6672
## Logging Configuration
6773

6874
Configuration of the logging component used by Icinga DB.

0 commit comments

Comments
 (0)