Add stale connection recovery to prevent pool exhaustion#30
Add stale connection recovery to prevent pool exhaustion#30
Conversation
…connections When connections are popped but never returned (leaked), the pool permanently loses those slots and eventually becomes fully exhausted. This adds a configurable maxUseTime that, when set, detects connections that have been checked out longer than the threshold and recovers their slots by allowing new connections to be created in their place. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
maxUseTimeconfiguration toPoolthat enables detection of leaked connections (connections checked out longer than the threshold)Connectionobjects viamarkCheckedOut()/getCheckedOutAt()maxUseTime=0) for full backwards compatibilityProblem
The Sentry error "Pool 'console' is empty (size 75)" (CLOUD-3K4N, 3267 events) occurs when all pool connections are checked out and none are returned. This happens when connections are leaked — popped but never reclaimed due to consumer code errors, timeouts, or edge cases. Without recovery, leaked connections permanently reduce pool capacity until full exhaustion.
How it works
markCheckedOut())pop()fails to get a connection andmaxUseTime > 0, it scans active connections for any exceeding the thresholdconnectionsCreateddecremented)Test plan
testPoolRecoversStaleConnections— verifies stale connections are detected and new connections created in their placetestPoolDoesNotRecoverNonStaleConnections— verifies non-stale connections are not evictedtestPoolStaleRecoveryDisabledByDefault— verifies the feature is off whenmaxUseTime=0pint --preset psr12) passesphpstan) passes🤖 Generated with Claude Code