diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 58cc0ed0c94..76f85532a90 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -211,6 +211,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 c23bfb1094d..57e78760b01 100644 --- a/solr/core/src/java/org/apache/solr/update/PeerSync.java +++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java @@ -267,7 +267,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; @@ -281,19 +292,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; }