Skip to content

Enforce min_pool_size with prewarm and retain replenishment#135

Merged
vadv merged 3 commits intomasterfrom
feature/min-pool-size-enforcement
Feb 26, 2026
Merged

Enforce min_pool_size with prewarm and retain replenishment#135
vadv merged 3 commits intomasterfrom
feature/min-pool-size-enforcement

Conversation

@vadv
Copy link
Copy Markdown
Collaborator

@vadv vadv commented Feb 26, 2026

Summary

  • min_pool_size enforcement at runtime: After each connection retain cycle, pg_doorman checks pool sizes and creates new connections to maintain the configured minimum. Previously, min_pool_size was accepted in config but never applied.
  • Pool prewarm at startup: When min_pool_size is configured, connections are created immediately at startup, before the first retain cycle. This eliminates cold-start latency for the first clients after pg_doorman restart.
  • Documentation: Updated fields.yaml descriptions to mention prewarm behavior, regenerated reference configs.

dmitrivasilyev added 3 commits February 26, 2026 09:50
Add Pool::replenish() method that creates new connections up to a
desired count, stopping on first failure to avoid hammering a failing
server. After the retain cycle closes expired/idle connections, check
each pool against its min_pool_size and replenish the deficit.

Previously min_pool_size was configurable but never enforced at runtime:
pools started empty and retain could drop them to 0 even with
min_pool_size set. Now the retain task ensures pools stay at or above
the configured minimum.
What was needed: The min_pool_size implementation (replenish after retain) was missing
observability (silent failures on connection creation), changelog entry, and BDD test coverage.

Implementation: Added warn! logging when replenish fails to create connections (both in
Pool::replenish and retain_connections), added changelog entry under Bug Fixes in 3.3.1,
and created 2 BDD scenarios testing replenish-after-startup and maintain-after-expiry behavior.
When min_pool_size is configured, pg_doorman now creates the minimum
number of connections immediately at startup, before the first retain
cycle. Previously, pools started empty and connections were only created
lazily on first client request or after the first retain interval
(default 60s). This eliminates cold-start latency for the first clients
connecting after pg_doorman restart.
@vadv vadv merged commit 18f1993 into master Feb 26, 2026
41 checks passed
@vadv vadv deleted the feature/min-pool-size-enforcement branch February 26, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant