Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-7935:fix race that can cause a NPE in openNewSearcher called from an update concurrent with a core reload

Yonik Seeleybc6a8d9fff38
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 071f8e37eda..581365ede3b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -139,6 +139,9 @@ Bug Fixes
* SOLR-7920: Resolve XSS issue in Admin UI Schema Browser (David Chiu via Upayavira)
+* SOLR-7935: Fix very rare race condition that can cause an update to fail
+ via NullPointerException during a core reload. (yonik)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index efa28b06fda..80707cb21ad 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1584,8 +1584,8 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
// SolrCore.verbose("start reopen from",previousSearcher,"writer=",writer);
- RefCounted<IndexWriter> writer = getUpdateHandler().getSolrCoreState()
- .getIndexWriter(null);
+ RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(null);
+
try {
if (writer != null) {
// if in NRT mode, open from the writer
@@ -1639,7 +1639,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
tmp = new SolrIndexSearcher(this, newIndexDir, getLatestSchema(),
(realtime ? "realtime":"main"), newReader, true, !realtime, true, directoryFactory);
} else {
- RefCounted<IndexWriter> writer = getUpdateHandler().getSolrCoreState().getIndexWriter(this);
+ RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this);
DirectoryReader newReader = null;
try {
newReader = indexReaderFactory.newReader(writer.get(), this);