implemented a mechanism to reconnect to the database after a 'MySQL server has gone away' error and to re-execute the query that failed, so that normal processing can continue