emergency error handling to counter sudden mysql deadlocks