You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mridulm (via GitHub)" <gi...@apache.org> on 2023/07/31 05:11:24 UTC

[GitHub] [spark] mridulm commented on a diff in pull request #40972: [SPARK-43301][CORE][SHUFFLE] BlockStoreClient getHostLocalDirs RPC supports IOException retry

mridulm commented on code in PR #40972:
URL: https://github.com/apache/spark/pull/40972#discussion_r1278798696


##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockStoreClient.java:
##########
@@ -188,6 +212,31 @@ public void onFailure(Throwable t) {
     }
   }
 
+  private <T> void retry(
+      int times,
+      final int maxRetries,
+      int delayMs,
+      Supplier<CompletableFuture<T>> action,
+      CompletableFuture<T> future) {
+    action.get()
+            .thenAccept(future::complete)
+            .exceptionally(e -> {
+              boolean isIOException = e instanceof IOException
+                      || (e.getCause() != null && e.getCause() instanceof IOException);
+              if (times >= maxRetries || !isIOException) {
+                future.completeExceptionally(e);
+              } else {
+                executorService.execute(() -> {

Review Comment:
   Schedule the execution, instead of occupying the thread actively for sleep.



##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockStoreClient.java:
##########
@@ -159,6 +168,21 @@ public void getHostLocalDirs(
       String[] execIds,
       CompletableFuture<Map<String, String[]>> hostLocalDirsCompletable) {
     checkInit();
+    int maxRetries = transportConf.maxIORetries();
+    int retryWaitTime = transportConf.ioRetryWaitTimeMs();
+    retry(1, maxRetries, retryWaitTime, () -> {

Review Comment:
   Start with `0`, so that a max retry of `1` will retry once.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org