Permalink
Browse files

Add debug logging to SQLite retry

  • Loading branch information...
LadyCailin committed Jan 3, 2019
1 parent 3aaeaed commit 0da70ce2b709e0d5d3f9da9b6843ddbcfd71a62e
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java
@@ -3,7 +3,9 @@
import com.laytonsmith.PureUtilities.Common.StringUtils;
import com.laytonsmith.PureUtilities.DaemonManager;
import com.laytonsmith.annotations.datasource;
import com.laytonsmith.core.CHLog;
import com.laytonsmith.core.MSVersion;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.persistence.io.ConnectionMixin;
import com.laytonsmith.persistence.io.ConnectionMixinFactory;
import java.io.IOException;
@@ -148,7 +150,12 @@ public boolean set0(DaemonManager dm, String[] key, String value) throws ReadOnl
// This one only happens with SETs
|| ex.getMessage().equals("cannot commit transaction - SQL statements in progress")) {
try {
Thread.sleep(getRandomSleepTime());
int sleepTime = getRandomSleepTime();
CHLog.GetLogger().d(CHLog.Tags.PERSISTENCE, "Got recoverable error from SQLite DB,"
+ " sleeping for " + sleepTime + " then potentially retrying. ("
+ ex.getMessage() + ")",
Target.UNKNOWN);
Thread.sleep(sleepTime);
} catch (InterruptedException ex1) {
//
}
@@ -242,7 +249,12 @@ public String get0(String[] key) throws DataSourceException {
} catch (SQLException ex) {
if(ex.getMessage().startsWith("[SQLITE_BUSY]")) {
try {
Thread.sleep(getRandomSleepTime());
int sleepTime = getRandomSleepTime();
CHLog.GetLogger().d(CHLog.Tags.PERSISTENCE, "Got recoverable error from SQLite DB,"
+ " sleeping for " + sleepTime + " then potentially retrying. ("
+ ex.getMessage() + ")",
Target.UNKNOWN);
Thread.sleep(sleepTime);
} catch (InterruptedException ex1) {
//
}

0 comments on commit 0da70ce

Please sign in to comment.