Enforce min_pool_size with prewarm and retain replenishment#135
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
min_pool_sizewas accepted in config but never applied.min_pool_sizeis 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.fields.yamldescriptions to mention prewarm behavior, regenerated reference configs.