CheckIndex and IndexWriter (w/ APPEND open mode) should not use SIS retry logic

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1628784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-10-01 17:55:48 +00:00
parent aa2f8bad25
commit 981bfba841
2 changed files with 18 additions and 2 deletions

View File

@ -24,6 +24,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@ -455,8 +456,15 @@ public class CheckIndex implements Closeable {
SegmentInfos sis = new SegmentInfos();
Status result = new Status();
result.dir = dir;
String[] files = dir.listAll();
String lastSegmentsFile = SegmentInfos.getLastCommitSegmentsFileName(files);
if (lastSegmentsFile == null) {
throw new IndexNotFoundException("no segments* file found in " + dir + ": files: " + Arrays.toString(files));
}
try {
sis.read(dir);
// Do not use SegmentInfos.read(Directory) since the spooky
// retrying it does is not necessary here (we hold the write lock):
sis.read(dir, lastSegmentsFile);
} catch (Throwable t) {
if (failFast) {
IOUtils.reThrow(t);

View File

@ -794,7 +794,15 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
// segments) pending:
changed();
} else {
segmentInfos.read(directory);
String[] files = directory.listAll();
String lastSegmentsFile = SegmentInfos.getLastCommitSegmentsFileName(files);
if (lastSegmentsFile == null) {
throw new IndexNotFoundException("no segments* file found in " + directory + ": files: " + Arrays.toString(files));
}
// Do not use SegmentInfos.read(Directory) since the spooky
// retrying it does is not necessary here (we hold the write lock):
segmentInfos.read(directory, lastSegmentsFile);
IndexCommit commit = config.getIndexCommit();
if (commit != null) {