diff --git a/CHANGELOG.md b/CHANGELOG.md index 05ff4ae843..ef0520f0bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ The types of changes are: ### Added - Adds last_monitored and enabled attributes to MonitorConfig [#4991](https://github.com/ethyca/fides/pull/4991) +### Fixed +- Fixed intermittent connection issues with Redshift by increasing timeout and preferring SSL in test connections [#4981](https://github.com/ethyca/fides/pull/4981) + ## [2.39.0](https://github.com/ethyca/fides/compare/2.38.1...2.39.0) ### Added diff --git a/src/fides/core/utils.py b/src/fides/core/utils.py index 239f9ac4ef..3ea7a02634 100644 --- a/src/fides/core/utils.py +++ b/src/fides/core/utils.py @@ -41,6 +41,7 @@ def get_db_engine(connection_string: str) -> Engine: ) if "redshift" in connection_string: connect_args["sslmode"] = "prefer" + connect_args["connect_timeout"] = 60 try: engine = sqlalchemy.create_engine(connection_string, connect_args=connect_args) except Exception as err: @@ -58,8 +59,15 @@ def validate_db_engine(connection_string: str) -> None: """ Use SQLAlchemy to create a DB engine. """ + # Pymssql doesn't support this arg + connect_args: Dict[str, Any] = ( + {"connect_timeout": 10} if "pymssql" not in connection_string else {} + ) + if "redshift" in connection_string: + connect_args["sslmode"] = "prefer" + connect_args["connect_timeout"] = 60 try: - engine = sqlalchemy.create_engine(connection_string) + engine = sqlalchemy.create_engine(connection_string, connect_args=connect_args) with engine.begin() as connection: connection.execute("SELECT 1") except SQLAlchemyError as error: