kfaraz commented on code in PR #17927:
URL: https://github.com/apache/druid/pull/17927#discussion_r2053277371


##########
server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java:
##########
@@ -208,28 +209,26 @@ public void unregisterListener()
     listenerExecutor.shutdownNow();
   }
 
-  private void stopAndCreateNewLeaderLatch()
+  private void closeLeaderLatchQuietly()

Review Comment:
   Done.



##########
server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java:
##########
@@ -105,29 +105,30 @@ public void isLeader()
             }
             catch (Exception ex) {
               log.makeAlert(ex, "listener becomeLeader() failed. Unable to 
become leader").emit();
-              stopAndCreateNewLeaderLatch();
-              startLeaderLatch();
+              notLeader();
             }
           }
 
           @Override
           public void notLeader()
           {
-            try {
-              if (!leader) {
-                log.warn("I'm being asked to stop being leader. But I am not 
the leader. Ignored event.");
-                return;
-              }
+            if (!leader) {
+              log.warn("I'm being asked to stop being leader. But I am not the 
leader. Ignored event.");
+              return;
+            }
+
+            // Stop the current latch and create a new one
+            leader = false;
+            closeLeaderLatchQuietly();
 
-              leader = false;
-              // give others a chance to become leader.
-              stopAndCreateNewLeaderLatch();
+            try {
               listener.stopBeingLeader();
-              startLeaderLatch();
             }
             catch (Exception ex) {
               log.makeAlert(ex, "listener.stopBeingLeader() failed. Unable to 
stopBeingLeader").emit();

Review Comment:
   Done.



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