From 3b5251fbd6135211d51db8fd1d81d134d2ea62a2 Mon Sep 17 00:00:00 2001 From: Kian Jones <11655409+kianjones9@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:59:43 -0800 Subject: [PATCH] fix: force statement_timeout=0 on all database connections (#9184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- letta/server/db.py | 1 + 1 file changed, 1 insertion(+) diff --git a/letta/server/db.py b/letta/server/db.py index 35ca098e..bdb41b05 100644 --- a/letta/server/db.py +++ b/letta/server/db.py @@ -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: