You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2020/10/13 12:12:34 UTC

[lucene-solr] branch branch_8x updated: SOLR-14776: Precompute the fingerprint during PeerSync (#1814)

This is an automated email from the ASF dual-hosted git repository.

shalin pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 0f2e389  SOLR-14776: Precompute the fingerprint during PeerSync (#1814)
0f2e389 is described below

commit 0f2e389c1346edaed76987cf73c53218110863bc
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Tue Oct 13 16:35:33 2020 +0530

    SOLR-14776: Precompute the fingerprint during PeerSync (#1814)
    
    After heavy indexing, the call to compute fingerprint takes awhile and slows the leader election. This commit computes the fingerprint in parallel with fetching the fingerprint from the other replicas.
    
    Co-authored-by: Shalin Shekhar Mangar <sh...@apache.org>
    
    (cherry picked from commit 9594ab3ac01c3449fde8163d44c9c27261585c9f)
---
 solr/CHANGES.txt                                   |  3 +++
 .../src/java/org/apache/solr/update/PeerSync.java  | 30 +++++++++++++---------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c89af85..3c66723 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -97,6 +97,9 @@ Optimizations
 
 * SOLR-14576 : Do not use SolrCore as keys in a WeakHashMap (noble)
 
+* SOLR-14776: Precompute fingerprint during PeerSync in parallel with fetching fingerprint from replicas.
+  (Cao Manh Dat, Mike Drob via shalin)
+
 Bug Fixes
 ---------------------
 
diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java b/solr/core/src/java/org/apache/solr/update/PeerSync.java
index b9684bd..6fb6626 100644
--- a/solr/core/src/java/org/apache/solr/update/PeerSync.java
+++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java
@@ -260,7 +260,18 @@ public class PeerSync implements SolrMetricProducer {
     for (String replica : replicas) {
       requestFingerprint(replica);
     }
-    
+
+    // We only compute fingerprint during leader election. Therefore after heavy indexing,
+    // the call to compute fingerprint takes awhile and slows the leader election.
+    // So we do it in parallel with fetching the fingerprint from the other replicas
+    IndexFingerprint ourFingerprint;
+    try {
+      ourFingerprint = IndexFingerprint.getFingerprint(core, Long.MAX_VALUE);
+    } catch (IOException e) {
+      log.warn("Could not confirm if we are already in sync. Continue with PeerSync");
+      return false;
+    }
+
     for (;;) {
       ShardResponse srsp = shardHandler.takeCompletedOrError();
       if (srsp == null) break;
@@ -274,19 +285,14 @@ public class PeerSync implements SolrMetricProducer {
         log.warn("Replica did not return a fingerprint - possibly an older Solr version or exception");
         continue;
       }
-      
-      try {
-        IndexFingerprint otherFingerprint = IndexFingerprint.fromObject(replicaFingerprint);
-        IndexFingerprint ourFingerprint = IndexFingerprint.getFingerprint(core, Long.MAX_VALUE);
-        if(IndexFingerprint.compare(otherFingerprint, ourFingerprint) == 0) {
-          log.info("We are already in sync. No need to do a PeerSync ");
-          return true;
-        }
-      } catch(IOException e) {
-        log.warn("Could not confirm if we are already in sync. Continue with PeerSync");
+
+      IndexFingerprint otherFingerprint = IndexFingerprint.fromObject(replicaFingerprint);
+      if(IndexFingerprint.compare(otherFingerprint, ourFingerprint) == 0) {
+        log.info("We are already in sync. No need to do a PeerSync ");
+        return true;
       }
     }
-    
+
     return false;
   }