Skip to content

Apache Lucene open-source search software

tests: try to track down the tlog-already-exists issue

Yonik Seeley9db16cd23b8d
diff --git a/solr/core/src/java/org/apache/solr/update/TransactionLog.java b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
index d5e2f09f2f8..85eeb7c40ab 100644
--- a/solr/core/src/java/org/apache/solr/update/TransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
@@ -55,6 +55,8 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class TransactionLog {
public static Logger log = LoggerFactory.getLogger(TransactionLog.class);
+ final boolean debug = log.isDebugEnabled();
+ final boolean trace = log.isTraceEnabled();
public final static String END_MESSAGE="SOLR_TLOG_END";
@@ -71,7 +73,6 @@ public class TransactionLog {
AtomicInteger refcount = new AtomicInteger(1);
Map<String,Integer> globalStringMap = new HashMap<String, Integer>();
List<String> globalStringList = new ArrayList<String>();
- final boolean debug = log.isDebugEnabled();
long snapshot_size;
int snapshot_numRecords;
@@ -156,6 +157,9 @@ public class TransactionLog {
addGlobalStrings(globalStrings);
}
} else {
+ if (start > 0) {
+ log.error("New transaction log already exists:" + tlogFile + " size=" + raf.length());
+ }
assert start==0;
if (start > 0) {
raf.setLength(0);
@@ -543,8 +547,8 @@ public class TransactionLog {
synchronized (TransactionLog.this) {
- if (debug) {
- log.debug("Reading log record. pos="+pos+" currentSize="+fos.size());
+ if (trace) {
+ log.trace("Reading log record. pos="+pos+" currentSize="+fos.size());
}
if (pos >= fos.size()) {
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index d4f09b9e1c4..d88420916eb 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -48,6 +48,7 @@ import java.util.concurrent.*;
public class UpdateLog implements PluginInfoInitialized {
public static Logger log = LoggerFactory.getLogger(UpdateLog.class);
public boolean debug = log.isDebugEnabled();
+ public boolean trace = log.isTraceEnabled();
public enum SyncLevel { NONE, FLUSH, FSYNC }
@@ -141,6 +142,9 @@ public class UpdateLog implements PluginInfoInitialized {
this.uhandler = uhandler;
if (dataDir.equals(lastDataDir)) {
+ if (debug) {
+ log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", next id=" + id, " this is a reopen... nothing else to do.");
+ }
// on a normal reopen, we currently shouldn't have to do anything
return;
}
@@ -150,6 +154,10 @@ public class UpdateLog implements PluginInfoInitialized {
tlogFiles = getLogList(tlogDir);
id = getLastLogId() + 1; // add 1 since we will create a new log for the next update
+ if (debug) {
+ log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", existing tlogs=" + Arrays.asList(tlogFiles) + ", next id=" + id);
+ }
+
TransactionLog oldLog = null;
for (String oldLogName : tlogFiles) {
File f = new File(tlogDir, oldLogName);
@@ -247,8 +255,8 @@ public class UpdateLog implements PluginInfoInitialized {
map.put(cmd.getIndexedId(), ptr);
}
- if (debug) {
- log.debug("TLOG: added id " + cmd.getPrintableId() + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ if (trace) {
+ log.trace("TLOG: added id " + cmd.getPrintableId() + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
}
}
}
@@ -274,8 +282,8 @@ public class UpdateLog implements PluginInfoInitialized {
oldDeletes.put(br, ptr);
}
- if (debug) {
- log.debug("TLOG: added delete for id " + cmd.id + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ if (trace) {
+ log.trace("TLOG: added delete for id " + cmd.id + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
}
}
}
@@ -312,8 +320,8 @@ public class UpdateLog implements PluginInfoInitialized {
LogPtr ptr = new LogPtr(pos, cmd.getVersion());
- if (debug) {
- log.debug("TLOG: added deleteByQuery " + cmd.query + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ if (trace) {
+ log.trace("TLOG: added deleteByQuery " + cmd.query + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
}
}
}
@@ -385,6 +393,7 @@ public class UpdateLog implements PluginInfoInitialized {
public void preSoftCommit(CommitUpdateCommand cmd) {
debug = log.isDebugEnabled(); // refresh our view of debugging occasionally
+ trace = log.isTraceEnabled();
synchronized (this) {
diff --git a/solr/testlogging.properties b/solr/testlogging.properties
index 4a09a265675..f70a5b58fb4 100644
--- a/solr/testlogging.properties
+++ b/solr/testlogging.properties
@@ -1,4 +1,7 @@
handlers=java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level=FINEST
.level=SEVERE
+org.apache.solr.update.UpdateLog.level=FINEST
+org.apache.solr.update.TransactionLog.level=FINEST
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter