Index: src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (revision 1221103) +++ src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -75,6 +75,7 @@ private HServerAddress metaLocation; private final int defaultTimeout; private boolean stopped = false; + private boolean instantiatedzkw = false; private HConnection abortable; public static final byte [] ROOT_REGION = @@ -133,7 +134,15 @@ throws IOException { this.conf = conf; this.connection = connection; - this.zookeeper = (zk == null) ? this.connection.getZooKeeperWatcher() : zk; + if (zk == null) { + // Create our own. Set flag so we tear it down on stop. + this.zookeeper = + new ZooKeeperWatcher(conf, "catalogtracker-on-" + connection.toString(), + abortable); + instantiatedzkw = true; + } else { + this.zookeeper = zk; + } if (abortable == null) { this.abortable = this.connection; } @@ -190,6 +199,9 @@ // IOException}, in reality, the implementation would never do that. LOG.error("Attempt to close catalog tracker's connection failed.", e); } + if (this.instantiatedzkw) { + this.zookeeper.close(); + } // Call this and it will interrupt any ongoing waits on meta. synchronized (this.metaAvailable) { this.metaAvailable.notifyAll();