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 never being released.
  • Loading branch information
yhabteab committed Oct 23, 2024
1 parent 3484476 commit 4c1fbac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions 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
6 changes: 6 additions & 0 deletions doc/03-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ do not need any manual adjustments.
| 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`. |
| wsrep_sync_wait | **Optional.** Enforce [Galera cluster](#galera-cluster) nodes to perform strict cluster-wide causality checks. Defaults to `7`. |

!!! info

The [Icinga DB HA](05-Distributed-Setups.md#high-availability) feature uses its own database connection, separate
from the other Icinga DB components, and this configuration cannot be altered by end users. Therefore, expect
Icinga DB to establish `max_connections` + `1` database connections.

## Logging Configuration

Configuration of the logging component used by Icinga DB.
Expand Down

0 comments on commit 4c1fbac

Please sign in to comment.