Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45971108D1 for ; Wed, 12 Feb 2014 17:03:02 +0000 (UTC) Received: (qmail 13392 invoked by uid 500); 12 Feb 2014 17:03:01 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 13206 invoked by uid 500); 12 Feb 2014 17:03:00 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 12902 invoked by uid 99); 12 Feb 2014 17:03:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Feb 2014 17:03:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Feb 2014 17:02:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DFC7B2388868; Wed, 12 Feb 2014 17:02:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1567678 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Date: Wed, 12 Feb 2014 17:02:35 -0000 To: commits@hbase.apache.org From: tedyu@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140212170235.DFC7B2388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tedyu Date: Wed Feb 12 17:02:35 2014 New Revision: 1567678 URL: http://svn.apache.org/r1567678 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.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1567678&r1=1567677&r2=1567678&view=diff ============================================================================== --- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original) +++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Wed Feb 12 17:02:35 2014 @@ -97,6 +97,7 @@ import org.apache.hadoop.hbase.util.hbck import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; 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.util.ReflectionUtils; import org.apache.hadoop.util.Tool; @@ -3863,49 +3864,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 tables = getIncludedTables(); - Collection tableDirs = new ArrayList(); - Path rootdir = FSUtils.getRootDir(getConf()); - if (tables.size() > 0) { - for (String t : tables) { - tableDirs.add(FSUtils.getTablePath(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 tables = getIncludedTables(); + Collection tableDirs = new ArrayList(); + Path rootdir = FSUtils.getRootDir(getConf()); + if (tables.size() > 0) { + for (String t : tables) { + tableDirs.add(FSUtils.getTablePath(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; }