# RDSProxy: Connection pool exhausted for database 'mydb'

- **ID:** `cloud/aws-rds-proxy-connection-pool-exhausted`
- **Domain:** cloud
- **Category:** resource_error
- **Error Code:** `ConnectionPoolExhausted`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

RDS Proxy's maximum connection pool size for the target database is reached, often due to too many concurrent connections or long-running queries holding connections open.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| RDS Proxy 1.0 | active | — | — |
| Aurora MySQL 8.0 | active | — | — |
| Aurora PostgreSQL 15 | active | — | — |
| RDS for MySQL 8.0 | active | — | — |

## Workarounds

1. **Increase RDS Proxy's MaxConnectionsPercent and SessionPinningFilters in the proxy target group: `aws rds modify-db-proxy-target-group --db-proxy-name my-proxy --target-group-name default --connection-pool-config MaxConnectionsPercent=90,SessionPinningFilters=["EXCLUDE_VARIABLE_SETS"]`. Also increase database max_connections: `aws rds modify-db-instance --db-instance-identifier my-db --db-parameter-group-name custom-params` with max_connections=500.** (85% success)
   ```
   Increase RDS Proxy's MaxConnectionsPercent and SessionPinningFilters in the proxy target group: `aws rds modify-db-proxy-target-group --db-proxy-name my-proxy --target-group-name default --connection-pool-config MaxConnectionsPercent=90,SessionPinningFilters=["EXCLUDE_VARIABLE_SETS"]`. Also increase database max_connections: `aws rds modify-db-instance --db-instance-identifier my-db --db-parameter-group-name custom-params` with max_connections=500.
   ```
2. **Optimize application code to close connections promptly using connection pooling libraries (e.g., HikariCP with maxLifetime=300000 and idleTimeout=600000). Set connection timeout in AWS Lambda: `import pymysql; conn = pymysql.connect(..., connect_timeout=5, read_timeout=30)`.** (90% success)
   ```
   Optimize application code to close connections promptly using connection pooling libraries (e.g., HikariCP with maxLifetime=300000 and idleTimeout=600000). Set connection timeout in AWS Lambda: `import pymysql; conn = pymysql.connect(..., connect_timeout=5, read_timeout=30)`.
   ```

## Dead Ends

- **** — RDS Proxy pool size is limited by the database's max_connections; increasing proxy percent alone does not help if the database limit is reached. (80% fail)
- **** — Restarting clears the pool temporarily, but the application will quickly exhaust it again if connections are not closed properly. (90% fail)
- **** — Multiple proxy endpoints share the same underlying database connection limit; this only distributes load but does not increase total pool size. (75% fail)
