diff --git a/lobbyconnection.html b/lobbyconnection.html index 79b0c9639..fb96c7106 100644 --- a/lobbyconnection.html +++ b/lobbyconnection.html @@ -43,7 +43,7 @@

Module server.lobbyconnection

import aiohttp from sqlalchemy import and_, func, select -from sqlalchemy.exc import DBAPIError +from sqlalchemy.exc import DBAPIError, OperationalError import server.metrics as metrics from server.db import FAFDatabase @@ -245,6 +245,16 @@

Module server.lobbyconnection

self.get_user_identifier(), cmd ) + except OperationalError: + # When the database goes down, SqlAlchemy will throw an OperationalError + self._logger.error("Encountered OperationalError on message received. This could indicate DB is down.") + await self.send({ + "command": "notice", + "style": "error", + "text": "Unable to connect to database. Please try again later." + }) + # Make sure to abort here to avoid a thundering herd problem. + await self.abort("Error connecting to database") except Exception as e: # pragma: no cover await self.send({"command": "invalid"}) self._logger.exception(e) @@ -1532,6 +1542,16 @@

Classes

self.get_user_identifier(), cmd ) + except OperationalError: + # When the database goes down, SqlAlchemy will throw an OperationalError + self._logger.error("Encountered OperationalError on message received. This could indicate DB is down.") + await self.send({ + "command": "notice", + "style": "error", + "text": "Unable to connect to database. Please try again later." + }) + # Make sure to abort here to avoid a thundering herd problem. + await self.abort("Error connecting to database") except Exception as e: # pragma: no cover await self.send({"command": "invalid"}) self._logger.exception(e) @@ -3934,6 +3954,16 @@

Methods

self.get_user_identifier(), cmd ) + except OperationalError: + # When the database goes down, SqlAlchemy will throw an OperationalError + self._logger.error("Encountered OperationalError on message received. This could indicate DB is down.") + await self.send({ + "command": "notice", + "style": "error", + "text": "Unable to connect to database. Please try again later." + }) + # Make sure to abort here to avoid a thundering herd problem. + await self.abort("Error connecting to database") except Exception as e: # pragma: no cover await self.send({"command": "invalid"}) self._logger.exception(e)