mlbiscoc commented on code in PR #4069:
URL: https://github.com/apache/solr/pull/4069#discussion_r2714303962
##########
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:
lastTermDoRecovery is set here but its possible recovery is deferred below
because of leader election now. Is that right? The old logic set it, then
actually does recovery regardless. Reading this, seems like there is a
possibility that `lastTermDoRecovery` is set to the new term but can skip
actually doing recovery further down. So the term this was set to is incorrect
based on the name if recovery is skipped?
--
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]