From 9d5d43ff866159efe1c367e8643a1403722ad31b Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 28 Jan 2015 18:20:55 +0000 Subject: [PATCH] LUCENE-6205: don't let doc values updates write in one thread at the same time as a merge kicking off in another git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1655426 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 4 ++++ .../src/java/org/apache/lucene/index/IndexWriter.java | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 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 clone their 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) Documentation diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 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 count assert 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);