True connection floor for the pool#1323
Open
shatilov-diman wants to merge 6 commits into
Open
Conversation
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.
Introduce
min_sizeas a true connection floor for the poolBackground
Previously,
Pool.min_sizecontrolled only how many connections were opened at startup — it had no effect on the pool's steady-state size. Once connections expired viamax_inactive_connection_lifetime, the pool could drain to zero regardless ofmin_size.What changed
min_size/init_sizesplit — the singlemin_sizeparameter is split into two distinct concepts:init_sizemin_sizerole)min_sizeConnection floor enforcement — when
max_inactive_connection_lifetimefires and the pool size is at or belowmin_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 configuredinit_size.Validation — the constructor now rejects invalid combinations:
init_size < 0init_size > max_sizeinit_size < min_sizemin_size > max_size(pre-existing, unchanged)Migration
Old code:
New code — keep old behaviour (no floor):
New code — with a connection floor of 2:
Tests added
test_pool_min_size_keeps_connections_alive— floor prevents expiry whenpool_size == min_sizetest_pool_min_size_partial_keep— excess connections expire; floor connections survivetest_pool_min_size_zero_allows_full_expiry—min_size=0restores the old drain-to-zero behaviourtest_pool_min_size_validation— all four invalid parameter combinations raiseValueErrortest_pool_init_size_and_min_size_getters—get_init_size()/get_min_size()return correct valuestest_pool_min_size_reconnect_after_expiry— a floor-kept connection remains functionalIssues
Closes #1268