public DatabaseException retryTransaction(Accessor writeConnection, DatabaseException databaseException, int retryCount, AbstractSession executionSession) {
if (writeConnection.getPool() == null) {
return super.retryTransaction(writeConnection, databaseException, retryCount, executionSession);
}
String poolName = writeConnection.getPool().getName();
DatabaseLogin login = getLogin();
int count = login.getQueryRetryAttemptCount();
DatabaseException exceptionToThrow = databaseException;
while (retryCount < count) {
getWriteConnections().remove(poolName);
//if connection is using external connection pooling then the event will be risen right after it connects.
if (!writeConnection.usesExternalConnectionPooling()) {
preReleaseConnection(writeConnection);
}
writeConnection.getPool().releaseConnection(writeConnection);
try {
// attempt to reconnect for a certain number of times.
// servers may take some time to recover.
++retryCount;
writeConnection = writeConnection.getPool().acquireConnection();
writeConnection.beginTransaction(this);
//passing the retry count will prevent a runaway retry where
// we can acquire connections but are unable to execute any queries
if (retryCount > 1) {
// We are retrying more than once lets wait to give connection time to restart.
//Give the failover time to recover.
Thread.currentThread().sleep(login.getDelayBetweenConnectionAttempts());
}
getWriteConnections().put(poolName, writeConnection);
writeConnection.createCustomizer(this);
//if connection is using external connection pooling then the event will be risen right after it connects.
if (!writeConnection.usesExternalConnectionPooling()) {