Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/src/db/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

from src.constants import CONN_STR

engine = create_engine(CONN_STR)
# pool_pre_ping: a pooled connection idle across the hourly-cron gap goes stale
# (Cloud SQL / db-f1-micro / the Cloud SQL proxy reap idle connections), and the
# next query raises "server closed the connection unexpectedly", 500ing the ETL
# trigger and stalling ingestion. pre_ping reconnects transparently; recycle
# drops connections older than 30 min proactively.
engine = create_engine(CONN_STR, pool_pre_ping=True, pool_recycle=1800)

Session = sessionmaker(bind=engine)

Expand Down