This is an automated email from the ASF dual-hosted git repository.

tolbertam pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f6eb4a6b31 Fix a bug in AutoRepair duration metric calculation if 
schedule finishes quickly
f6eb4a6b31 is described below

commit f6eb4a6b31d06108f073dba7dfa04732d2abbf7b
Author: jaydeepkumar1984 <chovatia.jayd...@gmail.com>
AuthorDate: Mon May 5 18:39:07 2025 -0700

    Fix a bug in AutoRepair duration metric calculation if schedule finishes 
quickly
    
    patch by Jaydeepkumar Chovatia; reviewed by Andy Tolbert for CASSANDRA-20622
---
 CHANGES.txt                                                       | 1 +
 src/java/org/apache/cassandra/repair/autorepair/AutoRepair.java   | 2 +-
 .../distributed/test/repair/AutoRepairSchedulerTest.java          | 8 ++++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 46e0afd6b0..efed7d42d4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.1
+ * Fix a bug in AutoRepair duration metric calculation if schedule finishes 
quickly (CASSANDRA-20622)
  * Fix AutoRepair flaky InJvm dtest (CASSANDRA-20620)
  * Increasing default for auto_repair.sstable_upper_threshold considering 
large Cassandra tables & revert three lines removed from CHANGES.txt due to a 
merge mistake (CASSANDRA-20586)
  * Fix token restrictions with MIN_TOKEN (CASSANDRO-20557)
diff --git a/src/java/org/apache/cassandra/repair/autorepair/AutoRepair.java 
b/src/java/org/apache/cassandra/repair/autorepair/AutoRepair.java
index 09e4a62a48..e5923e3c9c 100644
--- a/src/java/org/apache/cassandra/repair/autorepair/AutoRepair.java
+++ b/src/java/org/apache/cassandra/repair/autorepair/AutoRepair.java
@@ -469,7 +469,7 @@ public class AutoRepair
         
repairState.setSucceededTokenRangesCount(collectedRepairStats.succeededTokenRanges);
         
repairState.setSkippedTokenRangesCount(collectedRepairStats.skippedTokenRanges);
         repairState.setSkippedTablesCount(collectedRepairStats.skippedTables);
-        repairState.setNodeRepairTimeInSec((int) 
TimeUnit.MILLISECONDS.toSeconds(repairScheduleElapsedInMillis));
+        repairState.setNodeRepairTimeInSec((int) 
TimeUnit.MILLISECONDS.toSeconds(timeFunc.get() - startTimeInMillis));
         long timeInHours = 
TimeUnit.SECONDS.toHours(repairState.getNodeRepairTimeInSec());
         logger.info("Local {} repair time {} hour(s), stats: 
repairKeyspaceCount {}, " +
                     "repairTokenRangesSuccessCount {}, 
repairTokenRangesFailureCount {}, " +
diff --git 
a/test/distributed/org/apache/cassandra/distributed/test/repair/AutoRepairSchedulerTest.java
 
b/test/distributed/org/apache/cassandra/distributed/test/repair/AutoRepairSchedulerTest.java
index 4df58213aa..adca507082 100644
--- 
a/test/distributed/org/apache/cassandra/distributed/test/repair/AutoRepairSchedulerTest.java
+++ 
b/test/distributed/org/apache/cassandra/distributed/test/repair/AutoRepairSchedulerTest.java
@@ -48,6 +48,7 @@ import org.apache.cassandra.utils.FBUtilities;
 
 import static 
org.apache.cassandra.schema.SchemaConstants.DISTRIBUTED_KEYSPACE_NAME;
 import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.junit.Assert.assertEquals;
 
 /**
@@ -145,8 +146,11 @@ public class AutoRepairSchedulerTest extends TestBaseImpl
             AutoRepair.SLEEP_IF_REPAIR_FINISHES_QUICKLY = new 
DurationSpec.IntSecondsBound("2s");
 
             AutoRepairMetrics incrementalMetrics = 
AutoRepairMetricsManager.getMetrics(AutoRepairConfig.RepairType.INCREMENTAL);
+            // Since the AutoRepair sleeps up to 
SLEEP_IF_REPAIR_FINISHES_QUICKLY if the repair finishes quickly,
+            // so the "nodeRepairTimeInSec" metric should at least be greater 
than or equal to
+            // SLEEP_IF_REPAIR_FINISHES_QUICKLY
             Util.spinAssert(String.format("%s: AutoRepair has not yet 
completed one INCREMENTAL repair cycle", broadcastAddress),
-                            greaterThan(0L),
+                            greaterThanOrEqualTo(2L),
                             () -> 
incrementalMetrics.nodeRepairTimeInSec.getValue().longValue(),
                             5,
                             TimeUnit.MINUTES);
@@ -163,7 +167,7 @@ public class AutoRepairSchedulerTest extends TestBaseImpl
 
             AutoRepairMetrics fullMetrics = 
AutoRepairMetricsManager.getMetrics(AutoRepairConfig.RepairType.FULL);
             Util.spinAssert(String.format("%s: AutoRepair has not yet 
completed one FULL repair cycle", broadcastAddress),
-                            greaterThan(0L),
+                            greaterThanOrEqualTo(2L),
                             () -> 
fullMetrics.nodeRepairTimeInSec.getValue().longValue(),
                             5,
                             TimeUnit.MINUTES);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to