fix: force statement_timeout=0 on all database connections (#9184)

Cloud SQL's connection pooler can return connections with stale
session settings from previous clients. If any client (Datadog,
monitoring tools, manual psql) sets statement_timeout, that setting
persists on the pooled connection.

This explicitly sets statement_timeout=0 via asyncpg's server_settings
on every connection, ensuring consistent behavior regardless of
connection pool state.

🤖 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Kian Jones
2026-01-29 14:59:43 -08:00
committed by Caren Thomas
parent 9a8d381b14
commit 3b5251fbd6

View File

@@ -44,6 +44,7 @@ if not settings.disable_sqlalchemy_pooling:
"prepared_statement_name_func": lambda: f"__asyncpg_{uuid.uuid4()}__",
"statement_cache_size": 0,
"prepared_statement_cache_size": 0,
"server_settings": {"statement_timeout": "0"},
}
# Only add SSL if not already specified in connection string
if "sslmode" not in async_pg_uri and "ssl" not in async_pg_uri: