Resolution
The org.norg.pool.PoolExhaustedException occurs because the number of concurrent requests has reached the maxPoolSize limit. To resolve this, you must increase the maxPoolSize in your configuration file and restart the application. There are no documented or supported methods for dynamic pool scaling at runtime in the norg library.
Pool Behavior and Eviction
Based on the library's architecture, it is important to distinguish between idle connections and active transactions:
- Eviction Policy: The
evictionPolicy and idleTimeout only apply to connections that are currently idle (not checked out).
- Active Transactions: If a connection is tied to an open transaction, it is exempt from eviction, regardless of how long the transaction has been running or if it exceeds the
idleTimeout. The pool will not forcibly reclaim a connection while it is in use.
Likely Cause of Intermittent Exhaustion
If you are experiencing exhaustion despite having a seemingly adequate maxPoolSize, the cause is likely connection leakage or long-running transactions. Because active connections cannot be evicted, a few stalled sessions can effectively shrink the available pool, leading to exhaustion for new requests.
Recommended Action Steps
- Verify Current Limits: Check your
norg.properties or equivalent configuration to confirm the current maxPoolSize.
- Monitor Transaction Duration: Implement logging or use JMX metrics to track the time between connection checkout and return. Identify any transactions that remain open significantly longer than the average request.
- Scale and Restart: Increase the
maxPoolSize to accommodate peak bursts and perform a full application restart to apply the changes.
- Audit Resource Closure: Ensure all connections are wrapped in try-with-resources blocks or explicitly closed in a
finally block to prevent leaks.
Diagnostic Requirement
To determine if the issue is a capacity limit or a leak, please provide the average transaction duration compared to the frequency of the exception. If the exception occurs while transaction durations are low, the pool is undersized; if durations are high or increasing, you have a leak or a performance bottleneck.