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:
Cao Manh Dat 2020-10-13 18:05:33 +07:00 committed by GitHub
parent b4f0442193
commit 9594ab3ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -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
---------------------

View File

@ -268,6 +268,17 @@ public class PeerSync implements SolrMetricProducer {
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;
@ -282,16 +293,11 @@ public class PeerSync implements SolrMetricProducer {
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");
}
}
return false;