-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Documentation
-
None
As described in the CMAP specification:
> If minPoolSize is set, the Connection Pool MUST have at least minPoolSize total Connections while it is "ready".
Currently, the Go driver waits for the background maintenance goroutine interval of 1 minute (or 10 seconds as proposed as part of GODRIVER-2038), not immediately when the pool size is below minPoolSize. Additionally, the current Go driver doesn't implement the "paused" or "ready" states.
Instead of waiting for the background maintenance goroutine interval to maintain minPoolSize, trigger a function or goroutine to create new connections immediately when pool size < minPoolSize.
Proposed implementation based on the current logic in PR 716:
- Add a new condition to condition() in createConnections() that allows a new connection to be created if there is a waiting checkOut() or the pool size is less than minPoolSize. E.g.:
condition := func() bool { checkOutWaiting := p.newConnWait.len() > 0 belowMinPoolSize := p.minSize > 0 && uint64(len(p.conns)) < p.minSize poolHasSpace := p.maxSize == 0 || uint64(len(p.conns)) < p.maxSize cancelled := ctx.Err() != nil return ((checkOutWaiting || belowMinPoolSize) && poolHasSpace) || cancelled }
- Remove nil check from p.newConnWait.popFront() and allow w to be nil. Handle any cases where the current code expects w to never be nil.
- Remove minPoolSize logic from maintain().