ivandika3 commented on code in PR #5549:
URL: https://github.com/apache/ozone/pull/5549#discussion_r1390111730


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -545,6 +552,39 @@ null, raftGroup, createRetryPolicy(conf), tlsConfig, 
conf)) {
             targetPeerId, reply);
         throw new IOException(reply.getException());
       }
+    } finally {
+      // Raft peers priorities need to be reset regardless of the result
+      // of transfer leadership
+      resetPriorities(conf, raftGroup, tlsConfig);
+    }
+  }
+
+  private static void resetPriorities(ConfigurationSource conf,
+      RaftGroup raftGroup, GrpcTlsConfig tlsConfig) {
+    List<RaftPeer> resetPeers = new ArrayList<>();
+    for (RaftPeer peer : raftGroup.getPeers()) {
+      resetPeers.add(
+          RaftPeer.newBuilder(peer)
+              .setPriority(NEUTRAL_PRIORITY)
+              .build()
+      );
+    }
+    LOG.info("Resetting Raft peers priorities after transfer leadership");
+    try (RaftClient raftClient = newRaftClient(SupportedRpcType.GRPC, null,
+        null, raftGroup, createRetryPolicy(conf), tlsConfig, conf)) {
+      RaftClientReply reply = raftClient.admin().setConfiguration(resetPeers);
+      if (reply.isSuccess()) {
+        LOG.info("Successfully reset priorities for division: {}",
+            resetPeers);
+      } else {
+        LOG.warn("Failed to reset priorities for division: {}." +
+            " Ratis reply: {}", resetPeers, reply);
+      }
+    } catch (IOException e) {
+      LOG.error("Exception thrown when trying to reset priorities for " +

Review Comment:
   Thank you for the review. I was thinking about this as well, but I think 
it's enough to reset priorities to be best effort and just log the error.



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