HBAseAdminの学友を使うのは注意します--一回のHBAse RegionServerの退出を覚えます


朝早く来て、RegionServerが切れました.
ロゴ、表示

2011-09-25 22:31:51,185 [main-SendThread(XXX:2181)] INFO org.apache.zookeeper.ClientCnxn: Unable to read additional data from server sessionid 0x30694969fba6a9, likely server has closed socket, closing socket connection and attempting reconnect


はっきりしていて、zookeeperに接続できなくなり、何度も再接続した後に失敗し、その後、regionserverは終了しました.
この機械は特殊です.私はHBAseのavailability監視カメラを走ったからです.
コードはとても簡単ですが、これが原因ではないかと心配しています.
それで

netstat -anp|grep 2181

見ると、果たして、このプロセスは3千近くのzookeeper connectionを占めています.client側がzookeeperに接続するconnectionには制限があり、defaultは30で、ここでは3000に設定しています.これによりregionserverはzookeeperのconnectionを取得できないため終了する.
監視の論理が簡単なので、疑問はこのような文に落ちた.

		try {
			HBaseAdmin.checkHBaseAvailable(hbaseConfig);
		} catch (MasterNotRunningException e) {
			logger.error(e.getMessage(),e);
			return new GangliaData("HBase Cluster Availability", e.getMessage() , 0);
		} catch (ZooKeeperConnectionException e) {
			logger.error(e.getMessage(),e);
			return new GangliaData("HBase Cluster Availability", e.getMessage() , 0);
		}

そこでcheckHBAseAvailableのコードを見て、

  public static void checkHBaseAvailable(Configuration conf)
  throws MasterNotRunningException, ZooKeeperConnectionException {
    Configuration copyOfConf = HBaseConfiguration.create(conf);
    copyOfConf.setInt("hbase.client.retries.number", 1);
    new HBaseAdmin(copyOfConf);
  }

ここではconf,newをコピーした新しいHBAseAdminを作成できる場合はcluster availableを証明します.そうしないと異常が放出されます.
ただし、この文ではHBAseAdminのインスタンスが作成され、コンストラクション関数ではzookeeperを接続するconnectionが作成され、解放されません.

 public HBaseAdmin(Configuration c)
  throws MasterNotRunningException, ZooKeeperConnectionException {
    this.conf = HBaseConfiguration.create(c);
    this.connection = HConnectionManager.getConnection(this.conf);
    this.pause = this.conf.getLong("hbase.client.pause", 1000);
    this.numRetries = this.conf.getInt("hbase.client.retries.number", 10);
    this.retryLongerMultiplier = this.conf.getInt("hbase.client.retries.longer.multiplier", 10);
    this.connection.getMaster();
  }

最後にネットを調べてみると、果たして、これはHBAseのバグ、HBAse 4417です.
修正の方法は

Index: src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java	(revision 1171389)
+++ src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java	(working copy)
@@ -1254,6 +1254,7 @@
   throws MasterNotRunningException, ZooKeeperConnectionException {
     Configuration copyOfConf = HBaseConfiguration.create(conf);
     copyOfConf.setInt("hbase.client.retries.number", 1);
-    new HBaseAdmin(copyOfConf);
+    HBaseAdmin admin = new HBaseAdmin(copyOfConf);
+    HConnectionManager.deleteConnection(admin.getConfiguration(), false);
   }
 }