@Override
    @SuppressWarnings("PMD.PreserveStackTrace")
    public <R, X extends Exception> R inTransaction(Handle handle,
                                                    HandleCallback<R, X> callback) throws X {
        final Configuration config = handle.getConfig(Configuration.class);
        int attempts = 1 + config.maxRetries;

        Deque<Exception> failures = new ArrayDeque<>();
        while (true) {
            try {
                R result = getDelegate().inTransaction(handle, callback);
                config.onSuccess.accept(new ArrayList<>(failures));
                return result;
            } catch (Exception last) {
                // throw immediately if the exception is unexpected
                if (!isSqlState(config.serializationFailureSqlState, last)) {
                    throw last;
                }

                failures.addLast(last);
                config.onFailure.accept(new ArrayList<>(failures));

                // no more attempts left? Throw ALL the exceptions! \o/
                attempts -= 1;
                if (attempts <= 0) {
                    Exception toThrow = failures.removeLast();
                    while (!failures.isEmpty()) {
                        toThrow.addSuppressed(failures.removeLast());
                    }
                    throw Sneaky.throwAnyway(toThrow);
                }
            }
        }
    }
A TransactionHandler that automatically retries transactions that fail due to
serialization failures, which can generally be resolved by automatically
retrying the transaction.  Any HandleCallback used under this runner
should be aware that it may be invoked multiple times and should be idempotent.
core/src/main/java/org/jdbi/v3/core/transaction/SerializableTransactionRunner.java