candlepin/candlepin — pull request #731 by dgoodwin (2014-10-07 13:23:36+00:00)
Title: Correctly re-fire failed jobs.

Previous implementation was looking to catch PersistenceException, but the job
we're most in need of refires (refresh pools) watch catching all Exceptions and
re-throwing as something else, so as it stands it looks like the refire
mechanism was not working correctly, at least for this job.

Additionally we need to detect MySQL transient deadlock exceptions which need
to be retried, triggered frequently due to mysql gap locking on indexes just
with concurrent inserts. We don't have MySQL driver in classpath, so we need to
watch out for SqlException as well as PersistenceException and try a refire if
either occurrs. Sadly this is showing up wrapped in a RuntimeException, thus
the cause checking.