lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject lucene-solr:branch_5x: SOLR-9310: PeerSync fails on a node restart due to IndexFingerPrint mismatch
Date Wed, 31 Aug 2016 15:41:04 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_5x 4f6e25467 -> afcc8c05d


SOLR-9310: PeerSync fails on a node restart due to IndexFingerPrint mismatch


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/afcc8c05
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/afcc8c05
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/afcc8c05

Branch: refs/heads/branch_5x
Commit: afcc8c05dd2c13a0cb0165674931a99decf98373
Parents: 4f6e254
Author: Noble Paul <noble@apache.org>
Authored: Wed Aug 31 21:10:55 2016 +0530
Committer: Noble Paul <noble@apache.org>
Committed: Wed Aug 31 21:10:55 2016 +0530

----------------------------------------------------------------------
 .../apache/solr/search/SolrIndexSearcher.java   | 25 ++++++++++++++++++--
 .../solr/cloud/PeerSyncReplicationTest.java     |  1 -
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/afcc8c05/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
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 f0441aa..f86e44e 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -31,7 +31,9 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -79,6 +81,7 @@ import org.apache.solr.schema.TrieIntField;
 import org.apache.solr.schema.TrieLongField;
 import org.apache.solr.search.facet.UnInvertedField;
 import org.apache.solr.search.stats.StatsSource;
+import org.apache.solr.update.IndexFingerprint;
 import org.apache.solr.update.SolrIndexConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,8 +161,10 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
   
   private String path;
   private final boolean reserveDirectory;
-  private boolean createdDirectory; 
-  
+  private boolean createdDirectory;
+  private final Map<Long, IndexFingerprint> maxVersionFingerprintCache = new ConcurrentHashMap<>();
+
+
   private static DirectoryReader getReader(SolrCore core, SolrIndexConfig config, DirectoryFactory
directoryFactory, String path) throws IOException {
     DirectoryReader reader = null;
     Directory dir = directoryFactory.get(path, DirContext.DEFAULT, config.lockType);
@@ -2392,6 +2397,22 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
     return super.explain(QueryUtils.makeQueryable(query), doc);
   }
 
+  /** @lucene.internal
+   * gets a cached version of the IndexFingerprint for this searcher
+   **/
+  public IndexFingerprint getIndexFingerprint(long maxVersion) throws IOException {
+    IndexFingerprint fingerprint = maxVersionFingerprintCache.get(maxVersion);
+    if (fingerprint != null) return fingerprint;
+    // possibly expensive, so prevent more than one thread from calculating it for this searcher
+    synchronized (maxVersionFingerprintCache) {
+      fingerprint = maxVersionFingerprintCache.get(maxVersionFingerprintCache);
+      if (fingerprint != null) return fingerprint;
+      fingerprint = IndexFingerprint.getFingerprint(this, maxVersion);
+      maxVersionFingerprintCache.put(maxVersion, fingerprint);
+      return fingerprint;
+    }
+  }
+
   /////////////////////////////////////////////////////////////////////
   // SolrInfoMBean stuff: Statistics and Module Info
   /////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/afcc8c05/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
index 458a283..9a6a629 100644
--- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
@@ -8,7 +8,6 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.lucene.util.LuceneTestCase.Slow;


Mime
View raw message