Skip to content

Commit

Permalink
Gracefully handle Redshift transient connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Dec 12, 2023
1 parent a397fc7 commit 39776f3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/brad/connection/redshift_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,16 @@ def close_sync(self) -> None:
self._connection.close()

def is_connection_lost_error(self, ex: Exception) -> bool:
# TODO: Determine how to check for lost connection errors.
if isinstance(ex, redshift_errors.InterfaceError):
return True
message = repr(ex)
for phrase in _CONNECTION_LOST_PHRASES:
if phrase in message:
return True
return False


_CONNECTION_LOST_PHRASES = [
"server socket closed",
"EOF occurred in violation of protocol",
]

0 comments on commit 39776f3

Please sign in to comment.