Query Retry on Exception
Heimdall supports capturing and retrying queries based on the exceptions returned by the underlying JDBC driver. This allows a variety of conditions that would otherwise break an application's processing flow, and allow retry logic to kick in, potentially resolving the issue. This is most useful for transient errors, such as during a failover, a deadlock situation, etc. For example, in order to support a graceful failover of a MySQL cluster (including Aurora), the following rule can be used:
This retry logic is not foolproof however--if in a transaction, retries should not be automatically performed, but should be resolved at the application level. It is impossible to cleanly retry all queries in a multi-query transaction, as one query can result from state that has changed since the transaction started. In auto-commit situations however, this retry logic can be useful to minimize disruption of the application, and to prevent connections from being dropped.