From 2ac3521c5f94e76544ff733f30d89abed0fb16cb Mon Sep 17 00:00:00 2001 From: Askaholic Date: Sat, 20 Apr 2024 15:18:05 +0000 Subject: [PATCH] deploy: 6312b1e20273a8762738ea7322b12860fc92b0e4 --- lobbyconnection.html | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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)