Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 552781) +++ CHANGES.txt (working copy) @@ -1,4 +1,4 @@ -Lucene Change Log +Lucene Change Log $Id$ @@ -167,6 +167,10 @@ 23. LUCENE-913: Two consecutive score() calls return different scores for Boolean Queries. (Michael Busch, Doron Cohen) +24. LUCENE-948: Fix FNFE exception caused by stale NFS client + directory listing caches when writers on different machines are + sharing an index over NFS. (Mike McCandless) + New features 1. LUCENE-759: Added two n-gram-producing TokenFilters. Index: src/java/org/apache/lucene/index/IndexWriter.java =================================================================== --- src/java/org/apache/lucene/index/IndexWriter.java (revision 552781) +++ src/java/org/apache/lucene/index/IndexWriter.java (working copy) @@ -875,6 +875,8 @@ if (commitPending) { segmentInfos.write(directory); // now commit changes + if (infoStream != null) + infoStream.println("close: wrote segments file \"" + segmentInfos.getCurrentSegmentFileName() + "\""); deleter.checkpoint(segmentInfos, true); commitPending = false; rollbackSegmentInfos = null; @@ -1362,6 +1364,8 @@ private void checkpoint() throws IOException { if (autoCommit) { segmentInfos.write(directory); + if (infoStream != null) + infoStream.println("checkpoint: wrote segments file \"" + segmentInfos.getCurrentSegmentFileName() + "\""); } else { commitPending = true; } Index: src/java/org/apache/lucene/index/IndexFileDeleter.java =================================================================== --- src/java/org/apache/lucene/index/IndexFileDeleter.java (revision 552781) +++ src/java/org/apache/lucene/index/IndexFileDeleter.java (working copy) @@ -23,6 +23,7 @@ import org.apache.lucene.store.Directory; import java.io.IOException; +import java.io.FileNotFoundException; import java.io.PrintStream; import java.util.Map; import java.util.HashMap; @@ -120,6 +121,9 @@ throws CorruptIndexException, IOException { this.infoStream = infoStream; + if (infoStream != null) + message("init: current segments file is \"" + segmentInfos.getCurrentSegmentFileName() + "\""); + this.policy = policy; this.directory = directory; @@ -153,13 +157,29 @@ message("init: load commit \"" + fileName + "\""); } SegmentInfos sis = new SegmentInfos(); - sis.read(directory, fileName); - CommitPoint commitPoint = new CommitPoint(sis); - if (sis.getGeneration() == segmentInfos.getGeneration()) { - currentCommitPoint = commitPoint; + try { + sis.read(directory, fileName); + } catch (FileNotFoundException e) { + // LUCENE-948: on NFS (and maybe others), if + // you have writers switching back and forth + // between machines, it's very likely that the + // dir listing will be stale and will claim a + // file segments_X exists when in fact it + // doesn't. So, we catch this and handle it + // as if the file does not exist + if (infoStream != null) { + message("init: hit FileNotFoundException when loading commit \"" + fileName + "\"; skipping this commit point"); + } + sis = null; } - commits.add(commitPoint); - incRef(sis, true); + if (sis != null) { + CommitPoint commitPoint = new CommitPoint(sis); + if (sis.getGeneration() == segmentInfos.getGeneration()) { + currentCommitPoint = commitPoint; + } + commits.add(commitPoint); + incRef(sis, true); + } } } }