Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-13314

Fix NPE in HMaster.getClusterStatus()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0.1, 1.1.0, 2.0.0
    • None
    • None

    Description

      On a test cluster we got a

      java.lang.NullPointerException
        at org.apache.hadoop.hbase.master.HMaster.getClusterStatus(HMaster.java:1742)
        at org.apache.hadoop.hbase.master.balancer.ClusterStatusChore.chore(ClusterStatusChore.java:50)
        at org.apache.hadoop.hbase.Chore.run(Chore.java:87)
      

      In HMaster.getClusterStatus() we have a couple of NPE.
      listChildrenNoWatch() may return null if the node is not found

      try {
        backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,
         this.zooKeeper.backupMasterAddressesZNode); <--- THIS MAY RETURN NULL
      } catch (KeeperException e) {
        LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);
        backupMasterStrings = new ArrayList<String>(0);
      }
      List<ServerName> backupMasters = new ArrayList<ServerName>(
            backupMasterStrings.size()); <--- WE DON'T CHECK FOR NULL
      

      then below, we build ClusterStatus with args that may be null

      String clusterId = fileSystemManager != null ?
        fileSystemManager.getClusterId().toString() : null;
      Map<String, RegionState> regionsInTransition = assignmentManager != null ?
        assignmentManager.getRegionStates().getRegionsInTransition() : null;
      String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;
      Map<ServerName, ServerLoad> onlineServers = null;
      Set<ServerName> deadServers = null;
      if (serverManager != null) {
        deadServers = serverManager.getDeadServers().copyServerNames();
        onlineServers = serverManager.getOnlineServers();
      }
      return new ClusterStatus(VersionInfo.getVersion(), clusterId,
        onlineServers, deadServers, serverName, backupMasters,
        regionsInTransition, coprocessors, balancerOn);
      

      In ClusterStatus equals(), hashCode(), toString() we don't check for nulls

      Attachments

        1. HBASE-13314-v0.patch
          9 kB
          Matteo Bertozzi
        2. HBASE-13314-v1.patch
          9 kB
          Matteo Bertozzi
        3. HBASE-13314-v1.patch
          9 kB
          Matteo Bertozzi

        Activity

          People

            mbertozzi Matteo Bertozzi
            mbertozzi Matteo Bertozzi
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: