fix: disable asyncpg prepared statement cache to prevent ProgrammingError at startup

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/e0178422-af66-4a2c-9cfe-13d750965c1a
This commit is contained in:
copilot-swe-agent[bot]
2026-03-24 16:09:42 +00:00
parent c7686a49ea
commit 1f2aa54e43
3 changed files with 7 additions and 0 deletions
+5
View File
@@ -9,12 +9,17 @@ from sqlalchemy.orm import declarative_base
from app.core.config import settings
# Create async engine
# prepared_statement_cache_size=0 disables SQLAlchemy's asyncpg prepared-statement
# LRU cache. This prevents ProgrammingError("cached statement plan is invalid") when
# CREATE TYPE / CREATE TABLE DDL (run via create_all at startup) invalidates previously
# cached statement plans on the same connection.
engine = create_async_engine(
settings.DATABASE_URL,
echo=settings.DEBUG,
pool_size=settings.DATABASE_POOL_SIZE,
max_overflow=settings.DATABASE_MAX_OVERFLOW,
pool_pre_ping=True,
connect_args={"prepared_statement_cache_size": 0},
)
# Create async session factory