fix: postgres timeout issues during heavy load

This commit is contained in:
Stijnvandenbroek
2026-03-10 14:47:36 +00:00
parent 508da573fa
commit 1b29efd649
5 changed files with 150 additions and 20 deletions

View File

@@ -18,15 +18,25 @@ def _elementary_schema_exists() -> bool:
port=os.environ.get("POSTGRES_PORT", "5432"),
dbname=os.environ["POSTGRES_DB"],
)
engine = create_engine(url)
with engine.connect() as conn:
return bool(
conn.execute(
text(
"SELECT 1 FROM information_schema.schemata WHERE schema_name = 'elementary'"
)
).scalar()
)
engine = create_engine(
url,
pool_pre_ping=True,
connect_args={"connect_timeout": 10},
)
from data_platform.resources import _retry_on_operational_error
def _query():
with engine.connect() as conn:
return bool(
conn.execute(
text(
"SELECT 1 FROM information_schema.schemata WHERE schema_name = 'elementary'"
)
).scalar()
)
return _retry_on_operational_error(_query)
@op