Skip to content

Apache Lucene open-source search software

SOLR-12670: RecoveryStrategy logs wrong wait time when retrying recovery

Shalin Shekhar Mangar887055d892e6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 82f8453e634..3460bc7ac20 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -239,6 +239,8 @@ Bug Fixes
* SOLR-12649: CloudSolrClient retries requests unnecessarily exception from server (noble, shalin)
+* SOLR-12670: RecoveryStrategy logs wrong wait time when retrying recovery. (shalin)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index 5de9581cce0..f361324293d 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -422,11 +423,12 @@ public class RecoveryStrategy implements Runnable, Closeable {
try {
// Wait an exponential interval between retries, start at 5 seconds and work up to a minute.
- // If we're at attempt >= 4, there's no point computing pow(2, retries) because the result
+ // If we're at attempt >= 4, there's no point computing pow(2, retries) because the result
// will always be the minimum of the two (12). Since we sleep at 5 seconds sub-intervals in
// order to check if we were closed, 12 is chosen as the maximum loopCount (5s * 12 = 1m).
- double loopCount = retries < 4 ? Math.min(Math.pow(2, retries), 12) : 12;
- LOG.info("Wait [{}] seconds before trying to recover again (attempt={})", loopCount, retries);
+ int loopCount = retries < 4 ? (int) Math.min(Math.pow(2, retries), 12) : 12;
+ LOG.info("Wait [{}] seconds before trying to recover again (attempt={})",
+ TimeUnit.MILLISECONDS.toSeconds(loopCount * startingRecoveryDelayMilliSeconds), retries);
for (int i = 0; i < loopCount; i++) {
if (isClosed()) {
LOG.info("Recovery for core {} has been closed", core.getName());