I don't like this, not only the sleep, but the fact that it will keep retrying a query that failed and stall any other query forever. The Database class code will automatically retry forever if it failed due to MySQL crash/lost connection, so the error here is more likely due to bad syntax.