mirror of https://github.com/apache/lucene.git
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 <shalin@apache.org>
This commit is contained in:
parent
b4f0442193
commit
9594ab3ac0
|
@ -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
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue