Commit 5ee64ebf authored by Andre Freyssinet's avatar Andre Freyssinet

Fixes an error in the calculation of the delay between 2 connection attempts.

parent 40b638d5
...@@ -482,35 +482,40 @@ public abstract class DBTransaction extends AbstractTransaction implements DBTra ...@@ -482,35 +482,40 @@ public abstract class DBTransaction extends AbstractTransaction implements DBTra
lastexc = null; lastexc = null;
completed = true; completed = true;
} catch (SQLException sqle) { } catch (SQLException sqle) {
if (logmon.isLoggable(BasicLevel.DEBUG))
logmon.log(BasicLevel.WARN, "DBTransaction, commit: try to reconnect", sqle);
else
logmon.log(BasicLevel.WARN, "DBTransaction, commit: try to reconnect - " + sqle.getMessage());
lastexc = sqle; lastexc = sqle;
retry += 1; retry += 1;
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (startRetry == 0L) startRetry = time; if (startRetry == 0L) startRetry = time;
if ((connectRetryCount > 0) && (retry > connectRetryCount)) {
logmon.log(BasicLevel.WARN, "DBTransaction, commit: maximum number of reconnection attempts reached: " + connectRetryCount);
break;
}
if ((connectRetryMaxPeriod > 0L) && ((time - startRetry) > connectRetryMaxPeriod)) {
logmon.log(BasicLevel.WARN, "DBTransaction, commit: reconnection period exceeded: " + connectRetryMaxPeriod);
break;
}
if ((connectRetryCount > 0) && (retry > connectRetryCount)) break; if (logmon.isLoggable(BasicLevel.DEBUG))
if ((connectRetryMaxPeriod > 0L) && ((time - startRetry) > connectRetryMaxPeriod)) break; logmon.log(BasicLevel.WARN, "DBTransaction, commit: try to reconnect", sqle);
else
logmon.log(BasicLevel.WARN, "DBTransaction, commit: try to reconnect - " + sqle.getMessage());
try { try {
if (lastTry == 0L) { // Do not wait the 1st time.
// It's the first retry do not wait. if (lastTry != 0L) {
lastTry = time; // Wait for at least configured delay since last attempt to connect
} else {
// Wait for at least configured delay
long delay = connectRetryMinDelay - (time - lastTry); long delay = connectRetryMinDelay - (time - lastTry);
lastTry = time;
try { try {
if (delay > 0) Thread.sleep(delay); if (delay > 0) Thread.sleep(delay);
} catch (InterruptedException exc) {} } catch (InterruptedException exc) {}
} }
lastTry = System.currentTimeMillis();
connectDB(); connectDB();
createPreparedStatement(); createPreparedStatement();
} catch (IOException exc) {} } catch (IOException exc) {
logmon.log(BasicLevel.INFO, "DBTransaction, commit: cannot reconnect" + exc.getMessage());
}
} }
} while (!completed); } while (!completed);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment