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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user