Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractDatabaseEngine function getConnection fixes #287

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,8 @@ public synchronized Connection getConnection() throws RetryLimitExceededExceptio
}

try {

if (maximumNumberOfTries > 0) {
if (retries == (maximumNumberOfTries / 2) || retries == (maximumNumberOfTries - 1)) {
logger.error("The connection to the database was lost. Remaining retries: {}", (maximumNumberOfTries - retries));
notificationLogger.error("The connection to the database was lost. Remaining retries: {}", (maximumNumberOfTries - retries));
} else {
logger.debug("Retrying ({}/{}) in {} seconds...", retries, maximumNumberOfTries, TimeUnit.MILLISECONDS.toSeconds(retryInterval));
}
logger.debug("Retrying ({}/{}) in {} seconds...", retries, maximumNumberOfTries, TimeUnit.MILLISECONDS.toSeconds(retryInterval));
} else {
logger.debug("Retry number {} in {} seconds...", retries, TimeUnit.MILLISECONDS.toSeconds(retryInterval));
if (retries % 10 == 0) {
Expand All @@ -388,9 +382,7 @@ public synchronized Connection getConnection() throws RetryLimitExceededExceptio
Thread.sleep(retryInterval);
connect(); // this sets the new object.


// recover state.

try {
recover();
} catch (final Exception e) {
Expand All @@ -406,7 +398,11 @@ public synchronized Connection getConnection() throws RetryLimitExceededExceptio
} catch (final SQLException ex) {
logger.debug("Connection failed.");

if (maximumNumberOfTries > 0 && retries > maximumNumberOfTries) {
if (retries == (maximumNumberOfTries / 2) || retries == (maximumNumberOfTries - 1)) {
logger.error("The connection to the database was lost. Remaining retries: {}", (maximumNumberOfTries - retries));
notificationLogger.error("The connection to the database was lost. Remaining retries: {}", (maximumNumberOfTries - retries));
}
else if (maximumNumberOfTries > 0 && retries >= maximumNumberOfTries) {
throw new RetryLimitExceededException("Maximum number of retries for a connection exceeded.", ex);
}

Expand Down