SOLR-4467: Ephemeral directory implementations may not recover correctly because the code to clear the tlog files on startup is off.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1446928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-02-16 19:20:05 +00:00
parent 7dd591ba5d
commit b800d08400
2 changed files with 14 additions and 11 deletions

View File

@ -22,6 +22,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Vector;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrEventListener;
@ -87,13 +89,14 @@ public abstract class UpdateHandler implements SolrInfoMBean {
private void clearLog(PluginInfo ulogPluginInfo) {
if (ulogPluginInfo == null) return;
File tlogDir = UpdateLog.getTlogDir(core, ulogPluginInfo);
log.info("Clearing tlog files, tlogDir=" + tlogDir);
if (tlogDir.exists()) {
String[] files = UpdateLog.getLogList(tlogDir);
for (String file : files) {
File f = new File(file);
File f = new File(tlogDir, file);
boolean s = f.delete();
if (!s) {
log.error("Could not remove tlog file:" + f);
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not remove tlog file:" + f.getAbsolutePath());
}
}
}

View File

@ -1398,16 +1398,16 @@ public class UpdateLog implements PluginInfoInitialized {
public static File getTlogDir(SolrCore core, PluginInfo info) {
String dataDir = (String) info.initArgs.get("dir");
if (dataDir == null) {
String ulogDir = core.getCoreDescriptor().getUlogDir();
if (ulogDir != null) {
dataDir = ulogDir;
}
if (dataDir == null || dataDir.length() == 0) {
dataDir = core.getDataDir();
}
String ulogDir = core.getCoreDescriptor().getUlogDir();
if (ulogDir != null) {
dataDir = ulogDir;
}
if (dataDir == null || dataDir.length() == 0) {
dataDir = core.getDataDir();
}
return new File(dataDir, TLOG_NAME);
}