You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ke...@apache.org on 2026/03/23 02:31:10 UTC

(hadoop) branch trunk updated: HDFS-17892. RBF: permit not released during invokeConcurrent if getOrderedNamenodes throws an exception (#8345). Contributed by dParikesit.

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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new c7105018965 HDFS-17892. RBF: permit not released during invokeConcurrent if getOrderedNamenodes throws an exception (#8345). Contributed by dParikesit.
c7105018965 is described below

commit c7105018965f120eff70e0be209864c4f0e0add1
Author: Dimas Shidqi Parikesit <ds...@gmail.com>
AuthorDate: Sun Mar 22 22:31:04 2026 -0400

    HDFS-17892. RBF: permit not released during invokeConcurrent if getOrderedNamenodes throws an exception (#8345). Contributed by dParikesit.
    
    Reviewed-by: Jian Zhang <ke...@apache.org>
---
 .../server/federation/router/RouterRpcClient.java  | 72 ++++++++++++----------
 .../fairness/TestRouterHandlersFairness.java       |  7 ++-
 2 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
index a0c67958b05..674226c3004 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java
@@ -1599,48 +1599,54 @@ protected static <T extends RemoteLocationContext, R> Map<T, R> postProcessResul
     // transfer originCall & callerContext to worker threads of executor.
     final Call originCall = Server.getCurCall().get();
     final CallerContext originContext = CallerContext.getCurrent();
-    for (final T location : locations) {
-      String nsId = location.getNameserviceId();
-      boolean isObserverRead = isObserverReadEligible(nsId, m);
-      final List<? extends FederationNamenodeContext> namenodes =
-          getOrderedNamenodes(nsId, isObserverRead);
-      final Class<?> proto = method.getProtocol();
-      final Object[] paramList = method.getParams(location);
-      if (standby) {
-        // Call the objectGetter to all NNs (including standby)
-        for (final FederationNamenodeContext nn : namenodes) {
-          String nnId = nn.getNamenodeId();
-          final List<FederationNamenodeContext> nnList =
-              Collections.singletonList(nn);
-          T nnLocation = location;
-          if (location instanceof RemoteLocation) {
-            nnLocation = (T)new RemoteLocation(nsId, nnId, location.getDest());
+    try{
+      for (final T location : locations) {
+        String nsId = location.getNameserviceId();
+        boolean isObserverRead = isObserverReadEligible(nsId, m);
+        final List<? extends FederationNamenodeContext> namenodes =
+            getOrderedNamenodes(nsId, isObserverRead);
+        final Class<?> proto = method.getProtocol();
+        final Object[] paramList = method.getParams(location);
+        if (standby) {
+          // Call the objectGetter to all NNs (including standby)
+          for (final FederationNamenodeContext nn : namenodes) {
+            String nnId = nn.getNamenodeId();
+            final List<FederationNamenodeContext> nnList =
+                Collections.singletonList(nn);
+            T nnLocation = location;
+            if (location instanceof RemoteLocation) {
+              nnLocation = (T)new RemoteLocation(nsId, nnId, location.getDest());
+            }
+            orderedLocations.add(nnLocation);
+            callables.add(
+                () -> {
+                  transferThreadLocalContext(originCall, originContext);
+                  return invokeMethod(
+                      ugi, nnList, isObserverRead, proto, m, paramList);
+                });
           }
-          orderedLocations.add(nnLocation);
+        } else {
+          // Call the objectGetter in order of nameservices in the NS list
+          orderedLocations.add(location);
           callables.add(
               () -> {
                 transferThreadLocalContext(originCall, originContext);
                 return invokeMethod(
-                    ugi, nnList, isObserverRead, proto, m, paramList);
+                    ugi, namenodes, isObserverRead, proto, m, paramList);
               });
         }
-      } else {
-        // Call the objectGetter in order of nameservices in the NS list
-        orderedLocations.add(location);
-        callables.add(
-            () -> {
-              transferThreadLocalContext(originCall, originContext);
-              return invokeMethod(
-                  ugi, namenodes, isObserverRead, proto, m, paramList);
-            });
       }
-    }
 
-    if (rpcMonitor != null) {
-      rpcMonitor.proxyOp();
-    }
-    if (this.router.getRouterClientMetrics() != null) {
-      this.router.getRouterClientMetrics().incInvokedConcurrent(m);
+      if (rpcMonitor != null) {
+        rpcMonitor.proxyOp();
+      }
+      if (this.router.getRouterClientMetrics() != null) {
+        this.router.getRouterClientMetrics().incInvokedConcurrent(m);
+      }
+
+    } catch (IOException e) {
+      releasePermit(CONCURRENT_NS, ugi, method, controller);
+      throw e;
     }
 
     return getRemoteResults(method, timeOutMs, controller, orderedLocations, callables);
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/fairness/TestRouterHandlersFairness.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/fairness/TestRouterHandlersFairness.java
index 34d33ac5cc6..706796d8c75 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/fairness/TestRouterHandlersFairness.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/fairness/TestRouterHandlersFairness.java
@@ -215,19 +215,20 @@ public void testReleasedWhenExceptionOccurs(
     // Use renewLease test invokeConcurrent.
     Collection<RemoteLocation> locations = new ArrayList<>();
     locations.add(new RemoteLocation("ns0", "/", "/"));
+    locations.add(new RemoteLocation("ns1", "/", "/"));
     RemoteMethod renewLease = new RemoteMethod(
         "renewLease",
         new Class[]{java.lang.String.class, java.util.List.class},
         new Object[]{null, null});
     availablePermits =
-        rpcClient.getRouterRpcFairnessPolicyController().getAvailablePermits("ns0");
+        rpcClient.getRouterRpcFairnessPolicyController().getAvailablePermits(CONCURRENT_NS);
     LambdaTestUtils.intercept(IOException.class,  () -> {
       LOG.info("Use renewLease test invokeConcurrent.");
       rpcClient.invokeConcurrent(locations, renewLease);
     });
-    // Ensure that the semaphore is not acquired.
+    // Ensure that the concurrent semaphore is released.
     assertEquals(availablePermits,
-        rpcClient.getRouterRpcFairnessPolicyController().getAvailablePermits("ns0"));
+        rpcClient.getRouterRpcFairnessPolicyController().getAvailablePermits(CONCURRENT_NS));
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org