Closed magneticstain closed 5 years ago
Sentry issue: INQUISITION-4A
Looking at the traceback on Sentry, it looks like this was caused by an OperationError exception when Inquisition couldn't access the database. The database is up and running on the dev box I'm working on, and has been for some time. So not sure why it didn't recognize it.
But regardless, we need to fail this gracefully and make sure the error gets logged.
err
is the name of PyMYSQL's error library; instead of listing that, we should specify the exception we're expecting. Similar to https://github.com/magneticstain/Inquisition/blob/master/lib/inquisit/Inquisit.py#L63 .
The pymysql code specifically lists unexpected disconnect from the database as a condition that would throw a OpertionalError. https://github.com/PyMySQL/PyMySQL/blob/master/pymysql/err.py#L36
Exception raised for errors that are related to the operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.
An exception is generated when Revelation tries to insert a new alert into the Inquisition DB, but fails (for any reason). The intention is to rollback the transaction, but the try/catch to implement that fails:
This can be traced back to the tr/catch at line 74 in Revelation.py: