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

dineshkumar pushed a commit to branch ranger-2.6
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit f8444190679d9c4276a64ba350f6e1ffdca7f3a1
Author: Sanket Shelar <[email protected]>
AuthorDate: Tue Dec 31 15:45:51 2024 +0530

    RANGER-4520: Both usersync/tagsync instances becoming active and syncing 
users/tags
    
    Signed-off-by: Dineshkumar Yadav <[email protected]>
---
 .../src/main/java/org/apache/ranger/ha/ActiveInstanceState.java      | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/ranger-common-ha/src/main/java/org/apache/ranger/ha/ActiveInstanceState.java 
b/ranger-common-ha/src/main/java/org/apache/ranger/ha/ActiveInstanceState.java
index 6a7a0e7b8..1f3ce3aad 100644
--- 
a/ranger-common-ha/src/main/java/org/apache/ranger/ha/ActiveInstanceState.java
+++ 
b/ranger-common-ha/src/main/java/org/apache/ranger/ha/ActiveInstanceState.java
@@ -87,6 +87,11 @@ public class ActiveInstanceState {
                        Stat serverInfo = 
client.checkExists().forPath(getZnodePath(zookeeperProperties));
                        if (serverInfo == null) {
                                
client.create().withMode(CreateMode.EPHEMERAL).withACL(acls).forPath(getZnodePath(zookeeperProperties));
+                       } else {
+                               long sessionId = 
client.getZookeeperClient().getZooKeeper().getSessionId();
+                               if (sessionId != 
serverInfo.getEphemeralOwner()) {
+                                       throw new Exception("Not a leader 
forces it to rejoin the election ");
+                               }
                        }
                        
client.setData().forPath(getZnodePath(zookeeperProperties),
                                        
rangerServiceServerAddress.getBytes(Charset.forName("UTF-8")));

Reply via email to