Pool Coordinator — database-level connection limits
max_db_connections caps total backend connections per database across all user pools. When the cap is reached, the coordinator redistributes connections to keep p99 as uniform as possible across pools.
Pools with lower p99 get priority — they receive the freed connection. Eviction takes from the pool where losing a connection is least critical (highest p95 transaction time). The net effect: instead of one pool starving while another hoards idle connections, the coordinator equalizes the latency impact of a shared connection budget.
If reserve_pool_size is set, short bursts are absorbed by the reserve without evicting anyone. When nothing is evictable, callers wait up to reserve_pool_timeout (default 3 s) for a peer to return a connection.
Disabled by default (max_db_connections = 0) — zero overhead when not configured.
New config fields: max_db_connections, min_connection_lifetime, reserve_pool_size, reserve_pool_timeout, min_guaranteed_pool_size.
New admin commands: SHOW POOL_COORDINATOR, SHOW POOL_SCALING. Both exported as Prometheus metrics.
Thundering herd suppression
Backend connect() calls are capped at scaling_max_parallel_creates (default 2) per pool. Waiting clients receive connections via FIFO direct handoff as peers return them. Connections nearing server_lifetime expiry are pre-replaced in the background.
See the pool pressure documentation for details on the checkout algorithm, tuning, and alerts.
Improvements
- Runtime log level control.
SET log_level = 'debug'without restart. Per-module:SET log_level = 'warn,pg_doorman::pool::pool_coordinator=debug'. - Log readability overhaul. Consistent
[user@pool #cN]prefix,4m30sdurations, logfmt stats, escaped PG error newlines. - Smart session cleanup. If the client reset session state itself (
RESET ALL,DEALLOCATE ALL, etc.), pg_doorman skips its own cleanup — fewer queries to PostgreSQL. avg_xact_timecolumn inSHOW POOLS.
Full changelog: https://ozontech.github.io/pg_doorman/changelog.html
Pool Coordinator — лимиты соединений на уровне базы данных
max_db_connections ограничивает общее количество backend-соединений к базе данных для всех пулов пользователей. При достижении лимита координатор перераспределяет соединения так, чтобы p99 был максимально равномерным между пулами.
Пулы с коротким p99 получают приоритет — именно им отдаётся освободившееся соединение. Eviction забирает соединение у пула, для которого потеря наименее критична (наибольший p95 времени транзакции). Результат: вместо ситуации, когда один пул голодает, а другой держит idle-соединения, координатор выравнивает влияние общего бюджета соединений на latency каждого пула.
Если задан reserve_pool_size, короткие всплески поглощаются резервом без eviction. Когда eviction невозможен, клиент ждёт до reserve_pool_timeout (по умолчанию 3 с) пока peer-пул не вернёт соединение.
Выключен по умолчанию (max_db_connections = 0) — нулевой overhead, когда не настроен.
Новые параметры: max_db_connections, min_connection_lifetime, reserve_pool_size, reserve_pool_timeout, min_guaranteed_pool_size.
Новые admin-команды: SHOW POOL_COORDINATOR, SHOW POOL_SCALING. Оба экспортируются как Prometheus-метрики.
Подавление thundering herd
Количество одновременных connect() к backend ограничено scaling_max_parallel_creates (по умолчанию 2) на пул. Ожидающие клиенты получают соединения через FIFO direct handoff по мере их возврата. Соединения, приближающиеся к server_lifetime, заменяются фоновой задачей до истечения.
Подробности об алгоритме checkout, настройке и алертах — в документации pool pressure.
Улучшения
- Управление уровнем логирования в рантайме.
SET log_level = 'debug'без рестарта. Per-module:SET log_level = 'warn,pg_doorman::pool::pool_coordinator=debug'. - Переработка логов. Единый префикс
[user@pool #cN], длительности4m30s, stats в logfmt, экранирование переносов строк в ошибках PG. - Умная очистка сессии. Если клиент сам сбросил состояние (
RESET ALL,DEALLOCATE ALLи т.д.), pg_doorman не дублирует cleanup — меньше запросов к PostgreSQL. - Столбец
avg_xact_timeвSHOW POOLS.
Полный changelog: https://ozontech.github.io/pg_doorman/changelog.html