belliottsmith commented on code in PR #4434:
URL: https://github.com/apache/cassandra/pull/4434#discussion_r2454535279


##########
src/java/org/apache/cassandra/service/paxos/cleanup/PaxosCleanupLocalCoordinator.java:
##########
@@ -125,6 +141,31 @@ public static PaxosCleanupLocalCoordinator 
createForAutoRepair(SharedContext ctx
         return new PaxosCleanupLocalCoordinator(ctx, INTERNAL_SESSION, 
tableId, ranges, iterator, true);
     }
 
+    private boolean maybeDelay(UncommittedPaxosKey uncommitted)
+    {
+        if (!DatabaseDescriptor.getPaxosRepairRaceWait())
+            return false;
+
+
+        long txnTimeoutMillis = 
Math.max(getCasContentionTimeout(MILLISECONDS), 
getWriteRpcTimeout(MILLISECONDS));
+        long nowMillis = Clock.Global.currentTimeMillis();
+        long ballotElapsedMillis = nowMillis - 
MICROSECONDS.toMillis(uncommitted.ballot().unixMicros());
+
+        if (ballotElapsedMillis < 0 && Math.abs(ballotElapsedMillis) > 
SECONDS.toMillis(1))
+            logger.warn("Encountered ballot that is more than 1 second in the 
future, is there a clock sync issue? {}", uncommitted.ballot());
+
+        if (ballotElapsedMillis >= txnTimeoutMillis)
+            return false;
+
+        long sleepMillis = txnTimeoutMillis - ballotElapsedMillis;
+        logger.info("Paxos auto repair encountered a potentially in progress 
ballot, sleeping {}ms to allow the in flight operation to finish", sleepMillis);
+
+        delayed.add(new DelayedRepair(uncommitted, nowMillis + sleepMillis));
+        
ScheduledExecutors.scheduledFastTasks.schedule(this::scheduleKeyRepairsOrFinish,
 sleepMillis, MILLISECONDS);

Review Comment:
   I think we need to synchronise scheduleKeyRepairsOrFinish? Or wrap it in a 
synchronise call inside the lambda. Currently it inherits its safety from its 
callers



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