From 000dacdffa2fb401cbcf0c44651ca91566289447 Mon Sep 17 00:00:00 2001 From: Juraj Bubniak Date: Wed, 18 Aug 2021 15:15:13 +0200 Subject: [PATCH] Add support for pgbouncer 1.16. --- CHANGELOG.md | 5 +++++ docker-compose.yml | 16 ++++++++-------- internal/domain/domain.go | 2 ++ internal/sqlstore/sql.go | 6 ++++++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99ae99..1269191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.11.0 + +* Add support for PgBouncer 1.16. +* Update to github.com/prometheus/common v0.30.0. + ## 0.10.0 * Drop sqlx, use stdlib database. diff --git a/docker-compose.yml b/docker-compose.yml index ed8fa89..4ad5984 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" services: postgres: - image: "postgres:12.3-alpine" + image: "postgres:12.4-alpine" restart: always ports: - "5432:5432" @@ -11,14 +11,14 @@ services: POSTGRES_PASSWORD: "postgres" pgbouncer: - image: "tophfr/pgbouncer:1.12.0" + image: "bitnami/pgbouncer:1.16.0" restart: always environment: - DEFAULT_HOST: "postgres" - AUTH__POSTGRES: "postgres" - CONF__PGBOUNCER__POOL_MODE: "transaction" - CONF__PGBOUNCER__STATS_USERS: "postgres" - CONF__PGBOUNCER__IGNORE_STARTUP_PARAMETERS: "extra_float_digits" + POSTGRESQL_HOST: "postgres" + POSTGRESQL_USERNAME: "postgres" + POSTGRESQL_PASSWORD: "postgres" + PGBOUNCER_AUTH_TYPE: "trust" + PGBOUNCER_IGNORE_STARTUP_PARAMETERS: "extra_float_digits" depends_on: - postgres @@ -29,7 +29,7 @@ services: ports: - "9127:9127" environment: - DATABASE_URL: "postgres://postgres:postgres@pgbouncer:5432/pgbouncer?sslmode=disable&binary_parameters=yes" + DATABASE_URL: "postgres://postgres:postgres@pgbouncer:6432/pgbouncer?sslmode=disable&binary_parameters=yes" DEFAULT_LABELS: "instance=pg1 env=dev" depends_on: - pgbouncer diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 33dfd27..90091ba 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -32,6 +32,7 @@ type Pool struct { User string Active int64 Waiting int64 + CancelReq int64 ServerActive int64 ServerIdle int64 ServerUsed int64 @@ -50,6 +51,7 @@ type Database struct { Database string ForceUser string PoolSize int64 + MinPoolSize int64 ReservePool int64 PoolMode string MaxConnections int64 diff --git a/internal/sqlstore/sql.go b/internal/sqlstore/sql.go index f74c991..d026ff6 100644 --- a/internal/sqlstore/sql.go +++ b/internal/sqlstore/sql.go @@ -13,6 +13,7 @@ type pool struct { User string Active int64 Waiting int64 + CancelReq int64 ServerActive int64 ServerIdle int64 ServerUsed int64 @@ -30,6 +31,7 @@ type database struct { Database string ForceUser sql.NullString PoolSize int64 + MinPoolSize int64 ReservePool int64 PoolMode sql.NullString MaxConnections int64 @@ -152,6 +154,8 @@ func (s *Store) GetPools(ctx context.Context) ([]domain.Pool, error) { dest = append(dest, &row.Active) case "cl_waiting": dest = append(dest, &row.Waiting) + case "cl_cancel_req": + dest = append(dest, &row.CancelReq) case "sv_active": dest = append(dest, &row.ServerActive) case "sv_idle": @@ -238,6 +242,8 @@ func (s *Store) GetDatabases(ctx context.Context) ([]domain.Database, error) { dest = append(dest, &row.ForceUser) case "pool_size": dest = append(dest, &row.PoolSize) + case "min_pool_size": + dest = append(dest, &row.MinPoolSize) case "reserve_pool": dest = append(dest, &row.ReservePool) case "pool_mode":