slfan1989 commented on code in PR #14243:
URL: https://github.com/apache/iceberg/pull/14243#discussion_r2428183651


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ZkLockFactory.java:
##########
@@ -222,4 +240,32 @@ public void unlock() {
       }
     }
   }
+
+  RetryPolicy createRetryPolicy() {
+
+    ZKRetryPolicies policy;
+    try {
+      policy = ZKRetryPolicies.valueOf(retryPolicyName);
+    } catch (IllegalArgumentException e) {
+      policy = ZKRetryPolicies.EXPONENTIAL_BACKOFF;
+    }
+
+    switch (policy) {
+      case ONE_TIME:
+        return new RetryOneTime(baseSleepTimeMs);
+
+      case N_TIME:
+        return new RetryNTimes(maxRetries, baseSleepTimeMs);
+
+      case BOUNDED_EXPONENTIAL_BACKOFF:
+        return new BoundedExponentialBackoffRetry(baseSleepTimeMs, 
maxSleepTimeMs, maxRetries);

Review Comment:
   
   After reviewing the `ExponentialBackoffRetry` implementation, if 
`baseSleepTimeMs` == `maxSleepTimeMs` and `maxRetries` > 1, the retry interval 
calculation
   
   ```
   sleepTimeMs = Math.min(maxSleepTimeMs, baseSleepTimeMs * 2^retryCount)
   ```
   
   will always result in sleepTimeMs = maxSleepTimeMs.
   In this case, the exponential backoff effectively degrades into a 
fixed-interval retry strategy.
   
   The relevant code is as follows:
   
   
https://github.com/apache/curator/blob/3bc3ea1904c62b7e3e0b94a079a13fd88790df1b/curator-client/src/main/java/org/apache/curator/retry/ExponentialBackoffRetry.java#L65-L73
   
   ```
   protected long getSleepTimeMs(int retryCount, long elapsedTimeMs) {
     // copied from Hadoop's RetryPolicies.java
     long sleepMs = (long) baseSleepTimeMs * Math.max(1, random.nextInt(1 << 
(retryCount + 1)));
     if (sleepMs > maxSleepMs) {
         log.warn("Sleep extension too large ({}). Pinning to {}", sleepMs, 
maxSleepMs);
         sleepMs = maxSleepMs;
     }
     return sleepMs;
   }
   ```



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