Apache Solr open-source search software
LUCENE-6790: block commit while rollback runs
Michael McCandless690f6d6578bf
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 7f0ef3149f8..fe9e326499f 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -131,6 +131,10 @@ Bug Fixestoo low (no highlight) or determine inOrder wrong.(Tim Allison via David Smiley)+* LUCENE-6790: Fix IndexWriter thread safety when one thread is+ handling a tragic exception but another is still committing (Mike+ McCandless)+Other* LUCENE-6174: Improve "ant eclipse" to select right JRE for building.diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.javaindex 44dc049db68..e7589af752d 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java@@ -2014,15 +2014,19 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {// Ensure that only one thread actually gets to do the// closing, and make sure no commit is also in progress:- synchronized(commitLock) {- if (shouldClose(true)) {- rollbackInternal();- }+ if (shouldClose(true)) {+ rollbackInternal();}}private void rollbackInternal() throws IOException {+ // Make sure no commit is running, else e.g. we can close while another thread is still fsync'ing:+ synchronized(commitLock) {+ rollbackInternalNoCommit();+ }+ }+ private void rollbackInternalNoCommit() throws IOException {boolean success = false;if (infoStream.isEnabled("IW")) {