-
-
Notifications
You must be signed in to change notification settings - Fork 467
Description
Summary
When using PostgreSQL with AWS RDS Proxy, connections get unnecessarily pinned due to the DoctrineBundle automatically setting charset: 'utf8'
for PostgreSQL connections, even when no charset is explicitly configured. This causes the DBAL PostgreSQL driver to execute SET NAMES 'utf8'
, which AWS RDS Proxy cannot track, resulting in connection pinning.
Description
In ConnectionFactory.php
, the bundle automatically sets a default charset when none is provided.
When a charset parameter is set, the PostgreSQL PDO driver Driver/PDO/PgSQL/Driver.php
executes SET NAMES
query.
AWS RDS Proxy Impact
AWS RDS Proxy logs warnings like:
The client session was pinned to the database connection [dbConnection=xxx] for the remainder of the session. The proxy can't reuse this connection until the session ends. Reason: SQL changed session settings that the proxy doesn't track. Consider moving session configuration to the proxy's initialization query. Digest: "set names $1".
Expected Behavior
For PostgreSQL connections, when no explicit charset is configured by the user, no charset should be automatically set by the bundle, allowing the database to use its default encoding without executing SET NAMES
.
Current Workaround Status
There is currently no workaround for this issue:
- Omitting
charset
from configuration → automatically set to'utf8'
- Setting
charset: null
→ still automatically set to'utf8'
due toisset()
check - Setting
charset: ''
→ would still pass theisset()
check but results in invalid set names query
Environment
- DoctrineBundle version: 2.15.1
- Doctrine DBAL version: 4.3.2
- Database: PostgreSQL via AWS RDS with RDS Proxy
- PHP version: 8.3