HoustonPutman commented on code in PR #4069:
URL: https://github.com/apache/solr/pull/4069#discussion_r2714392014


##########
solr/core/src/java/org/apache/solr/cloud/RecoveringCoreTermWatcher.java:
##########
@@ -52,15 +53,55 @@ public boolean onTermChanged(ShardTerms terms) {
       if (solrCore.getCoreDescriptor() == null
           || solrCore.getCoreDescriptor().getCloudDescriptor() == null) return 
true;
       String coreNodeName = 
solrCore.getCoreDescriptor().getCloudDescriptor().getCoreNodeName();
-      if (terms.haveHighestTermValue(coreNodeName)) return true;
-      if (lastTermDoRecovery.get() < terms.getTerm(coreNodeName)) {
-        log.info(
-            "Start recovery on {} because core's term is less than leader's 
term", coreNodeName);
-        lastTermDoRecovery.set(terms.getTerm(coreNodeName));
-        solrCore
-            .getUpdateHandler()
-            .getSolrCoreState()
-            .doRecovery(solrCore.getCoreContainer(), 
solrCore.getCoreDescriptor());
+
+      // If we have the highest term, there is nothing to do
+      if (terms.haveHighestTermValue(coreNodeName)) {
+        return true;
+      }
+
+      long lastRecoveryTerm;
+      long newTerm;
+      synchronized (lastTermDoRecovery) {
+        lastRecoveryTerm = lastTermDoRecovery.get();
+        newTerm = terms.getTerm(coreNodeName);
+        if (lastRecoveryTerm < newTerm) {
+          lastTermDoRecovery.set(newTerm);

Review Comment:
   Yeah `lastTermDoRecovery` might be a bad name, but after leader election, 
recovery is guaranteed for these replicas at this term value. So while recovery 
is not explicitly being done here, we know that leader election will do the 
recovery. So `lastTermDoRecovery` is still technically correct, just assuming 
the leader election succeeds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to