You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2014/02/12 18:03:41 UTC

svn commit: r1567679 - /hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java

Author: tedyu
Date: Wed Feb 12 17:03:41 2014
New Revision: 1567679

URL: http://svn.apache.org/r1567679
Log:
HBASE-10508 Backport HBASE-10365 'HBaseFsck should clean up connection properly when repair is completed' to 0.94 and 0.96


Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1567679&r1=1567678&r2=1567679&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Wed Feb 12 17:03:41 2014
@@ -104,6 +104,7 @@ import org.apache.hadoop.hbase.util.hbck
 import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
@@ -3998,49 +3999,53 @@ public class HBaseFsck extends Configure
     // do the real work of hbck
     connect();
 
-    // if corrupt file mode is on, first fix them since they may be opened later
-    if (checkCorruptHFiles || sidelineCorruptHFiles) {
-      LOG.info("Checking all hfiles for corruption");
-      HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles);
-      setHFileCorruptionChecker(hfcc); // so we can get result
-      Collection<TableName> tables = getIncludedTables();
-      Collection<Path> tableDirs = new ArrayList<Path>();
-      Path rootdir = FSUtils.getRootDir(getConf());
-      if (tables.size() > 0) {
-        for (TableName t : tables) {
-          tableDirs.add(FSUtils.getTableDir(rootdir, t));
+    try {
+      // if corrupt file mode is on, first fix them since they may be opened later
+      if (checkCorruptHFiles || sidelineCorruptHFiles) {
+        LOG.info("Checking all hfiles for corruption");
+        HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles);
+        setHFileCorruptionChecker(hfcc); // so we can get result
+        Collection<TableName> tables = getIncludedTables();
+        Collection<Path> tableDirs = new ArrayList<Path>();
+        Path rootdir = FSUtils.getRootDir(getConf());
+        if (tables.size() > 0) {
+          for (TableName t : tables) {
+            tableDirs.add(FSUtils.getTableDir(rootdir, t));
+          }
+        } else {
+          tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(getConf()), rootdir);
         }
-      } else {
-        tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(getConf()), rootdir);
+        hfcc.checkTables(tableDirs);
+        hfcc.report(errors);
       }
-      hfcc.checkTables(tableDirs);
-      hfcc.report(errors);
-    }
 
-    // check and fix table integrity, region consistency.
-    int code = onlineHbck();
-    setRetCode(code);
-    // If we have changed the HBase state it is better to run hbck again
-    // to see if we haven't broken something else in the process.
-    // We run it only once more because otherwise we can easily fall into
-    // an infinite loop.
-    if (shouldRerun()) {
-      try {
-        LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix...");
-        Thread.sleep(sleepBeforeRerun);
-      } catch (InterruptedException ie) {
-        return this;
-      }
-      // Just report
-      setFixAssignments(false);
-      setFixMeta(false);
-      setFixHdfsHoles(false);
-      setFixHdfsOverlaps(false);
-      setFixVersionFile(false);
-      setFixTableOrphans(false);
-      errors.resetErrors();
-      code = onlineHbck();
+      // check and fix table integrity, region consistency.
+      int code = onlineHbck();
       setRetCode(code);
+      // If we have changed the HBase state it is better to run hbck again
+      // to see if we haven't broken something else in the process.
+      // We run it only once more because otherwise we can easily fall into
+      // an infinite loop.
+      if (shouldRerun()) {
+        try {
+          LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix...");
+          Thread.sleep(sleepBeforeRerun);
+        } catch (InterruptedException ie) {
+          return this;
+        }
+        // Just report
+        setFixAssignments(false);
+        setFixMeta(false);
+        setFixHdfsHoles(false);
+        setFixHdfsOverlaps(false);
+        setFixVersionFile(false);
+        setFixTableOrphans(false);
+        errors.resetErrors();
+        code = onlineHbck();
+        setRetCode(code);
+      }
+    } finally {
+      IOUtils.cleanup(null, connection, meta, admin);
     }
     return this;
   }