Introduce min_size as a true connection floor for the pool
Background
Previously, Pool.min_size controlled only how many connections were opened at startup — it had no effect on the pool's steady-state size. Once connections expired via max_inactive_connection_lifetime, the pool could drain to zero regardless of min_size.
What changed
min_size / init_size split — the single min_size parameter is split into two distinct concepts:
Parameter
Meaning
init_size
Number of connections opened when the pool is created (replaces the old min_size role)
min_size
Minimum number of live connections the pool must maintain at all times
Connection floor enforcement — when max_inactive_connection_lifetime fires and the pool size is at or below min_size, the holder re-schedules the expiry callback instead of closing the connection. This keeps a warm connection floor without blocking or reconnecting on demand.
New accessor — Pool.get_init_size() returns the configured init_size.
Validation — the constructor now rejects invalid combinations:
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
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.
Introduce min_size as a true connection floor for the pool
Background
Previously, Pool.min_size controlled only how many connections were opened at startup — it had no effect on the pool's steady-state size. Once connections expired via max_inactive_connection_lifetime, the pool could drain to zero regardless of min_size.
What changed
min_size / init_size split — the single min_size parameter is split into two distinct concepts:
Connection floor enforcement — when max_inactive_connection_lifetime fires and the pool size is at or below min_size, the holder re-schedules the expiry callback instead of closing the connection. This keeps a warm connection floor without blocking or reconnecting on demand.
New accessor — Pool.get_init_size() returns the configured init_size.
Validation — the constructor now rejects invalid combinations:
Migration
Old code:
New code — keep old behaviour (no floor):
New code — with a connection floor of 2:
Tests added
Issues
Closes #1268