HBASE-10365 HBaseFsck should clean up connection properly when repair is completed
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1560564 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d84c5f759c
commit
1fb3e0bb93
|
@ -103,6 +103,7 @@ import org.apache.hadoop.hbase.util.hbck.TableLockChecker;
|
||||||
import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
|
import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
|
import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
|
import org.apache.hadoop.io.IOUtils;
|
||||||
import org.apache.hadoop.security.AccessControlException;
|
import org.apache.hadoop.security.AccessControlException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.util.ReflectionUtils;
|
import org.apache.hadoop.util.ReflectionUtils;
|
||||||
|
@ -3923,49 +3924,53 @@ public class HBaseFsck extends Configured {
|
||||||
// do the real work of hbck
|
// do the real work of hbck
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
// if corrupt file mode is on, first fix them since they may be opened later
|
try {
|
||||||
if (checkCorruptHFiles || sidelineCorruptHFiles) {
|
// if corrupt file mode is on, first fix them since they may be opened later
|
||||||
LOG.info("Checking all hfiles for corruption");
|
if (checkCorruptHFiles || sidelineCorruptHFiles) {
|
||||||
HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles);
|
LOG.info("Checking all hfiles for corruption");
|
||||||
setHFileCorruptionChecker(hfcc); // so we can get result
|
HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles);
|
||||||
Collection<TableName> tables = getIncludedTables();
|
setHFileCorruptionChecker(hfcc); // so we can get result
|
||||||
Collection<Path> tableDirs = new ArrayList<Path>();
|
Collection<TableName> tables = getIncludedTables();
|
||||||
Path rootdir = FSUtils.getRootDir(getConf());
|
Collection<Path> tableDirs = new ArrayList<Path>();
|
||||||
if (tables.size() > 0) {
|
Path rootdir = FSUtils.getRootDir(getConf());
|
||||||
for (TableName t : tables) {
|
if (tables.size() > 0) {
|
||||||
tableDirs.add(FSUtils.getTableDir(rootdir, t));
|
for (TableName t : tables) {
|
||||||
|
tableDirs.add(FSUtils.getTableDir(rootdir, t));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(getConf()), rootdir);
|
||||||
}
|
}
|
||||||
} else {
|
hfcc.checkTables(tableDirs);
|
||||||
tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(getConf()), rootdir);
|
hfcc.report(errors);
|
||||||
}
|
}
|
||||||
hfcc.checkTables(tableDirs);
|
|
||||||
hfcc.report(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check and fix table integrity, region consistency.
|
// check and fix table integrity, region consistency.
|
||||||
int code = onlineHbck();
|
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);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue