UNI12345 commited on
Commit
05e89e4
·
1 Parent(s): e8aaec2

Fix database connection prepared statement cache size for PgBouncer pool compatibility

Browse files
Files changed (1) hide show
  1. app/database.py +3 -1
app/database.py CHANGED
@@ -8,12 +8,14 @@ if database_url.startswith("postgresql://"):
8
  database_url = database_url.replace("postgresql://", "postgresql+asyncpg://", 1)
9
 
10
  # Enable connection pooling options since we connect to Supabase
 
11
  engine = create_async_engine(
12
  database_url,
13
  echo=settings.DEBUG,
14
  pool_size=10,
15
  max_overflow=20,
16
- pool_pre_ping=True
 
17
  )
18
 
19
  AsyncSessionLocal = async_sessionmaker(
 
8
  database_url = database_url.replace("postgresql://", "postgresql+asyncpg://", 1)
9
 
10
  # Enable connection pooling options since we connect to Supabase
11
+ # Connect with prepared_statement_cache_size=0 to prevent PgBouncer prepared statement conflicts
12
  engine = create_async_engine(
13
  database_url,
14
  echo=settings.DEBUG,
15
  pool_size=10,
16
  max_overflow=20,
17
+ pool_pre_ping=True,
18
+ connect_args={"prepared_statement_cache_size": 0}
19
  )
20
 
21
  AsyncSessionLocal = async_sessionmaker(