Skip to content

Commit

Permalink
Increase Postgres connection timeout to 10 seconds (#182)
Browse files Browse the repository at this point in the history
## Changes
- Increase Postgres connection timeout to 10 seconds
- Remove QueuePool timeout

## Context
Database migrations are occasionally timing out in the
platform-test-flask repo.
Tuning this up to 10 seconds to see if that helps.
Also removing the QueuePool timeout which doesn't seem needed.
  • Loading branch information
lorenyu committed Aug 8, 2023
1 parent 987d0aa commit 40ff875
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/src/adapters/db/clients/postgres_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _configure_engine(self, db_config: PostgresDBConfig) -> sqlalchemy.engine.En
def get_conn() -> Any:
return psycopg2.connect(**get_connection_parameters(db_config))

conn_pool = pool.QueuePool(get_conn, max_overflow=10, pool_size=20, timeout=3)
conn_pool = pool.QueuePool(get_conn, max_overflow=10, pool_size=20)

# The URL only needs to specify the dialect, since the connection pool
# handles the actual connections.
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_connection_parameters(db_config: PostgresDBConfig) -> dict[str, Any]:
password=password,
port=db_config.port,
options=f"-c search_path={db_config.db_schema}",
connect_timeout=3,
connect_timeout=10,
sslmode=db_config.ssl_mode,
**connect_args,
)
Expand Down
2 changes: 1 addition & 1 deletion app/tests/src/adapters/db/clients/test_postgres_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def test_get_connection_parameters(monkeypatch: pytest.MonkeyPatch):
password=db_config.password,
port=db_config.port,
options=f"-c search_path={db_config.db_schema}",
connect_timeout=3,
connect_timeout=10,
sslmode="require",
)

0 comments on commit 40ff875

Please sign in to comment.