diff --git a/lib/galaxy/jobs/handler.py b/lib/galaxy/jobs/handler.py index 008a4eee0be4..f43496d5a656 100644 --- a/lib/galaxy/jobs/handler.py +++ b/lib/galaxy/jobs/handler.py @@ -18,7 +18,10 @@ Union, ) -from sqlalchemy.exc import OperationalError +from sqlalchemy.exc import ( + DBAPIError, + OperationalError, +) from sqlalchemy.sql.expression import ( and_, func, @@ -395,6 +398,10 @@ def __monitor_step(self): self.__handle_waiting_jobs() except StopSignalException: pass + except DBAPIError as e: + log.exception(f"Execution of a database operation failed due to the following exception: {e}") + self.sa_session.remove() + log.trace(monitor_step_timer.to_str()) def __handle_waiting_jobs(self):