Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-5783: fix mixing caching + non caching searchers, fix multiple registration of same searcher

Yonik Seeley2aa5585ede1e
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 015d339c7f1..b5e58b2cd35 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1477,7 +1477,7 @@ public final class SolrCore implements SolrInfoMBean {
newestSearcher.incref();
return newestSearcher;
- } else if (newestSearcher.get().getSchema() == getLatestSchema()) {
+ } else if (newestSearcher.get().isCachingEnabled() && newestSearcher.get().getSchema() == getLatestSchema()) {
// absolutely nothing has changed, can use the same searcher
// but log a message about it to minimize confusion
@@ -1872,6 +1872,13 @@ public final class SolrCore implements SolrInfoMBean {
private void registerSearcher(RefCounted<SolrIndexSearcher> newSearcherHolder) {
synchronized (searcherLock) {
try {
+ if (_searcher == newSearcherHolder) {
+ // trying to re-register the same searcher... this can now happen when a commit has been done but
+ // there were no changes to the index.
+ newSearcherHolder.decref(); // decref since the caller should have still incref'd (since they didn't know the searcher was the same)
+ return; // still execute the finally block to notify anyone waiting.
+ }
+
if (_searcher != null) {
_searcher.decref(); // dec refcount for this._searcher
_searcher=null;
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 9c970ac990b..be97d81e9d6 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -272,7 +272,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
// do this at the end since an exception in the constructor means we won't close
numOpens.incrementAndGet();
}
-
+
+ public boolean isCachingEnabled() { return cachingEnabled; }
+
public String getPath() {
return path;
}