Apache Lucene open-source search software
LUCENE-6205: don't let doc values updates write in one thread at the same time as a merge kicking off in another
Michael McCandless9d5d43ff8661
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 394aff722f8..f455a67aee2 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -470,6 +470,10 @@ Bug Fixes* LUCENE-6173: NumericTermAttribute and spatial/CellTokenStream do not clonetheir BytesRef(Builder)s. Also equals/hashCode was missing. (Uwe Schindler)++* LUCENE-6205: Fixed intermittent concurrency issue that could cause+ FileNotFoundException when writing doc values updates at the same+ time that a merge kicks off. (Mike McCandless)Documentationdiff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.javaindex 73a40af89f6..7b791dfda00 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java@@ -3927,7 +3927,14 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {// fix the reader's live docs and del countassert delCount > reader.numDeletedDocs(); // beware of zombies- SegmentReader newReader = new SegmentReader(info, reader, liveDocs, info.info.getDocCount() - delCount);+ SegmentReader newReader;++ synchronized (this) {+ // We must also sync on IW here, because another thread could be writing+ // new DV updates / remove old gen field infos files causing FNFE:+ newReader = new SegmentReader(info, reader, liveDocs, info.info.getDocCount() - delCount);+ }+boolean released = false;try {rld.release(reader);