mirror of https://github.com/apache/lucene.git
remove obsolete fileLength call in IndexFileDeleter: crashes during commit no longer result in 0-length segments_N files
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1677104 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cc371b4cdf
commit
b3fd1ef560
|
@ -143,8 +143,6 @@ final class IndexFileDeleter implements Closeable {
|
|||
|
||||
// First pass: walk the files and initialize our ref
|
||||
// counts:
|
||||
long currentGen = segmentInfos.getGeneration();
|
||||
|
||||
CommitPoint currentCommitPoint = null;
|
||||
String[] files = directory.listAll();
|
||||
|
||||
|
@ -179,14 +177,6 @@ final class IndexFileDeleter implements Closeable {
|
|||
if (infoStream.isEnabled("IFD")) {
|
||||
infoStream.message("IFD", "init: hit FileNotFoundException when loading commit \"" + fileName + "\"; skipping this commit point");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (SegmentInfos.generationFromSegmentsFileName(fileName) <= currentGen && directory.fileLength(fileName) > 0) {
|
||||
throw e;
|
||||
} else {
|
||||
// Most likely we are opening an index that
|
||||
// has an aborted "future" commit, so suppress
|
||||
// exc in this case
|
||||
}
|
||||
}
|
||||
if (sis != null) {
|
||||
final CommitPoint commitPoint = new CommitPoint(commitsToDelete, directory, sis);
|
||||
|
|
|
@ -73,7 +73,6 @@ import org.apache.lucene.store.RAMDirectory;
|
|||
import org.apache.lucene.store.SimpleFSLockFactory;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.InfoStream;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
@ -2321,7 +2320,9 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
BaseDirectoryWrapper dir = newDirectory();
|
||||
|
||||
// Create a corrupt first commit:
|
||||
dir.createOutput("segments_0", IOContext.DEFAULT).close();
|
||||
dir.createOutput(IndexFileNames.fileNameFromGeneration(IndexFileNames.PENDING_SEGMENTS,
|
||||
"",
|
||||
0), IOContext.DEFAULT).close();
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
int mode = i/2;
|
||||
|
@ -2343,9 +2344,6 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
} else {
|
||||
new IndexWriter(dir, iwc).rollback();
|
||||
}
|
||||
if (mode != 0) {
|
||||
fail("expected exception");
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
// OpenMode.APPEND should throw an exception since no
|
||||
// index exists:
|
||||
|
|
Loading…
Reference in New Issue