Change withTransactionModeRetry to allow the user to determine when to retry

withTransactionModeRetry previously would retry if a not_serializable exception
was thrown, but this can be a little too fine grained. There are cases when a
transaction should be retried when a unique_violation occurs (e.g., a race
condition occurs). This allows users to tune the retrying semantics to the
needs of their application.
Merge remote-tracking branch 'ocharles/general-transaction-retrying' into 0.3