Repository navigation
Description
Audit defects M15 and M16, reproduced independently by the endpoint test above, plus two further defects the regression tests surfaced.
1. A saturated pool returned nil forever
Get returned *s3.Client alone, and nil once currentSize == maxSize. The select carried a default arm, so it never reached its own time.After case — the timeout was dead code and a full pool failed instantly rather than waiting for the connection about to come back.
draw 0: client=true currentSize=1 idle=0
draw 1: client=true currentSize=2 idle=0
draw 2: client=true currentSize=3 idle=0
draw 3: client=false currentSize=3 idle=0
draw 4: client=false currentSize=3 idle=0
--- after returning one ---
draw after Put: client=true
All six call sites dereferenced the result unchecked, including executeWithAccelerationFallback — the path every GET and PUT takes. On the default 8-connection pool the ninth concurrent operation panicked and unmounted the filesystem under every open descriptor.
2. Close raced Put into a send on a closed channel
Put checked closed under the read lock, released it, then sent. Close took the write lock, set closed, then closed the channel. The losing interleaving is a send on a closed channel — a panic during unmount, on the path every deferred Put takes.
3. The pool overshot maxSize under concurrency
canCreateConnection and createConnection took the lock separately, so N concurrent callers all passed the capacity check before any incremented. Surfaced by a regression test: 16 concurrent workers against a pool of 4 ran the factory 16 times and discarded 12 clients on return.
4. Resize could deadlock the pool
Resize raised maxSize without touching the idle channel, whose buffer is fixed at construction. A capacity reservation for a slot with no buffer space makes the return block while holding the write lock.
Fix
Get/GetWithTimeoutreturn(*s3.Client, error)and block up to the timeout; the timeout error names the in-use count andstorage.s3.pool_sizePutdoes itsclosedcheck and send in one critical section;Closedrains rather than closes, and wakes blocked waiters via adonechannel so shutdown does not make them wait out the full timeout- reserving a slot is one atomic operation, and a factory failure releases the reservation
Resizerefuses to grow past the constructed capacity and says to raisestorage.s3.pool_sizeinstead; shrinking converges by dropping checked-out connections as they returnWarmuprespectsmaxSize, joins factory errors, honours context cancellation, and refuses a closed pool
pool_test.go covers exhaustion-waits-then-wakes, the timeout message, concurrent Put/Close across 50 rounds under -race, concurrent draw/return bounded by maxSize, and the Resize/Warmup edges.
Activity
scttfrdmn commentedon Aug 2, 2026
Fixed in v0.10.1 (
ae0423b).GetWithTimeoutreturns(*s3.Client, error)instead of a bare pointer that wasnilonce the pool saturated and was dereferenced unchecked at six call sites, including the one every GET and PUT reaches.Closeno longer closes a channel with unsynchronized producers still sending.