Github user kevinxu021 commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1427#discussion_r172736968 --- Diff: dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java --- @@ -151,8 +163,28 @@ public void connect() throws IOException, InterruptedException { this.zk=null; throw new IOException("Cannot connect to Zookeeper"); } - - LOG.debug("Zookeeper.State=" + this.zk.getState()); + + // Solve the forcible reconnection + // When zk reconn, the backup-master may take over the master, + // so current master should restart, and queues in /dcs/master/leader + if (LOG.isDebugEnabled()) { + LOG.debug("force = [" + force + "]. checkPath = [" + checkPath + "]"); + } + if (force && checkPath != null) { + try { + Stat stat = zk.exists(checkPath, false); + if (LOG.isDebugEnabled()) { + LOG.debug("stat = [" + stat + "]."); + } + if (stat == null) { + // this means master has change. + setSessionRecoverSuccessful(false); + } + } catch (KeeperException e) { + e.printStackTrace(); --- End diff -- Log messages in file.
---