This is an automated email from the ASF dual-hosted git repository.
stack pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push:
new d943197 HBASE-22713 [HBCK2] Add hdfs integrity report to 'filesystem'
command (#12)
d943197 is described below
commit d9431977639e2a111f21c58d72df943fd7fc436a
Author: Michael Stack <[email protected]>
AuthorDate: Thu Jul 18 17:14:32 2019 -0700
HBASE-22713 [HBCK2] Add hdfs integrity report to 'filesystem' command (#12)
Add check of hdfs 'integrity'. Produces report.
Fix a bug where we'd not run filesystem command.
Cleanup filesystem output to be more explicit
about what it does.
---
.../main/java/org/apache/hbase/FileSystemFsck.java | 11 ++++++++
.../src/main/java/org/apache/hbase/HBCK2.java | 14 +++++----
.../java/org/apache/hbase/hbck1/HBaseFsck.java | 33 ++++++++--------------
.../apache/hbase/hbck1/HFileCorruptionChecker.java | 28 +++++++++---------
.../org/apache/hbase/TestSchedulingRecoveries.java | 2 +-
5 files changed, 45 insertions(+), 43 deletions(-)
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
index d1d93b4..89b0d73 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
@@ -89,6 +89,17 @@ public class FileSystemFsck implements Closeable {
// Now check links.
hbaseFsck.setFixReferenceFiles(fix);
hbaseFsck.setFixHFileLinks(fix);
+ hbaseFsck.setCheckHdfs(true);
+ /*
+ The below are too radical for hbck2. They are filesystem changes only.
+ Need to connect them to hbase:meta and master; master should repair
+ holes and overlaps and adopt regions.
+
+ hbaseFsck.setFixHdfsOrphans(fix);
+ hbaseFsck.setFixHdfsHoles(fix);
+ hbaseFsck.setFixHdfsOverlaps(fix);
+ hbaseFsck.setFixTableOrphans(fix);
+ */
hbaseFsck.setShouldRerun();
hbaseFsck.offlineHbck();
} catch (ClassNotFoundException | InterruptedException e) {
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
index e4657e7..70a8ce2 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
@@ -107,7 +107,7 @@ public class HBCK2 extends Configured implements
org.apache.hadoop.util.Tool {
try (Admin admin = connection.getAdmin()) {
String serverVersion = admin.
getClusterMetrics(EnumSet.of(ClusterMetrics.Option.HBASE_VERSION)).getHBaseVersion();
- String [] thresholdVersions = supportedVersions == null?
+ String [] thresholdVersions = supportedVersions == null ||
supportedVersions.length == 0?
MINIMUM_HBCK2_VERSION: supportedVersions;
boolean supported = Version.check(serverVersion, thresholdVersions);
if (!supported) {
@@ -294,11 +294,13 @@ public class HBCK2 extends Configured implements
org.apache.hadoop.util.Tool {
// out.println(" -fixHFileLinks Try to offline lingering HFileLinks");
writer.println(" " + FILESYSTEM + " [OPTIONS] [<TABLENAME...]");
writer.println(" Options:");
- writer.println(" -f, --fix sideline corrupt hfiles, bad links and
references.");
- writer.println(" Report corrupt hfiles and broken links. Pass '--fix' to
sideline");
- writer.println(" corrupt files and links. Pass one or more tablenames to
narrow the");
- writer.println(" checkup. Default checks all tables. Modified regions
will need to be");
- writer.println(" reopened to pick-up changes.");
+ writer.println(" -f, --fix sideline corrupt hfiles, bad links, and
references.");
+ writer.println(" Report on corrupt hfiles, references, broken links, and
integrity.");
+ writer.println(" Pass '--fix' to sideline corrupt files and links.
'--fix' does NOT");
+ writer.println(" fix integrity issues; i.e. 'holes' or 'orphan' regions.
Pass one or");
+ writer.println(" more tablenames to narrow checkup. Default checks all
tables and");
+ writer.println(" restores 'hbase.version' if missing. Interacts with the
filesystem only!");
+ writer.println(" Modified regions need to be reopened to pick-up
changes.");
writer.println();
writer.println(" " + SET_REGION_STATE + " <ENCODED_REGIONNAME> <STATE>");
writer.println(" Possible region states:");
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
index cb51c82..59b6f71 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
@@ -165,13 +165,14 @@ import
org.apache.hbase.thirdparty.com.google.common.collect.Sets;
import org.apache.hbase.thirdparty.com.google.common.collect.TreeMultimap;
/**
- * HBaseFsck (hbck) is a tool for checking and repairing region consistency and
+ * HBaseFsck (hbck) is(WAS) a tool for checking and repairing region
consistency and
* table integrity problems in a corrupted HBase. This tool was written for
hbase-1.x.
- * Parts were subsequently ported here for use by hbck2 (hbck1 does not work
- * against hbase2; its presumptions about how hbase works do not hold for
hbase2).
- * <p>The main method has been removed from this class so it is not directly
- * accessible</p>
+ * It was then ported here for use by hbck2 (hbck1 does not work against
hbase2; its
+ * presumptions about how hbase works do not hold for hbase2). hbck2 exposes
pieces
+ * of this hbck1 but not all, intentionally. The main method has been removed
from
+ * this class so it is not directly accessible</p>
*
+ * <p>Below is the old overview for hbck1.</p>
* <p>
* Region consistency checks verify that hbase:meta, region deployment on
region
* servers and the state of data in HDFS (.regioninfo files) all are in
@@ -694,7 +695,7 @@ public class HBaseFsck extends Configured implements
Closeable {
*/
public void offlineHdfsIntegrityRepair() throws IOException,
InterruptedException {
// Initial pass to fix orphans.
- if (shouldCheckHdfs() && (shouldFixHdfsOrphans() || shouldFixHdfsHoles()
+ if (shouldCheckHdfs() || (shouldFixHdfsOrphans() || shouldFixHdfsHoles()
|| shouldFixHdfsOverlaps() || shouldFixTableOrphans())) {
LOG.info("Loading regioninfos HDFS");
// if nothing is happening this should always complete in two iterations.
@@ -1139,7 +1140,6 @@ public class HBaseFsck extends Configured implements
Closeable {
*/
private int restoreHdfsIntegrity() throws IOException, InterruptedException {
// Determine what's on HDFS
- LOG.info("Loading HBase regioninfo from HDFS...");
loadHdfsRegionDirs(); // populating regioninfo table.
int errs = errors.getErrorList().size();
@@ -1148,7 +1148,7 @@ public class HBaseFsck extends Configured implements
Closeable {
checkHdfsIntegrity(false, false);
if (errors.getErrorList().size() == errs) {
- LOG.info("No integrity errors. We are done with this phase. Glorious.");
+ LOG.info("No integrity errors.");
return 0;
}
@@ -1190,10 +1190,8 @@ public class HBaseFsck extends Configured implements
Closeable {
Configuration conf = getConf();
Path hbaseRoot = FSUtils.getRootDir(conf);
FileSystem fs = hbaseRoot.getFileSystem(conf);
- LOG.info("Computing mapping of all store files");
Map<String, Path> allFiles = FSUtils.getTableStoreFilePathMap(fs,
hbaseRoot,
new FSUtils.ReferenceFileFilter(fs), executor, null/*Used to emit
'progress' and thats it*/);
- LOG.info("Validating mapping using HDFS state");
for (Path path: allFiles.values()) {
Path referredToFile = StoreFileInfo.getReferredToFile(path);
if (fs.exists(referredToFile)) {
@@ -1246,11 +1244,9 @@ public class HBaseFsck extends Configured implements
Closeable {
Configuration conf = getConf();
Path hbaseRoot = FSUtils.getRootDir(conf);
FileSystem fs = hbaseRoot.getFileSystem(conf);
- LOG.info("Computing mapping of all link files");
Map<String, Path> allFiles = FSUtils
.getTableStoreFilePathMap(fs, hbaseRoot, new
FSUtils.HFileLinkFilter(), executor,
null/*Used to emit 'progress' w/o context.*/);
- LOG.info("Validating mapping using HDFS state");
for (Path path : allFiles.values()) {
// building HFileLink object to gather locations
HFileLink actualLink = HFileLink.buildFromHFileLinkPattern(conf, path);
@@ -1785,17 +1781,16 @@ public class HBaseFsck extends Configured implements
Closeable {
*/
private void logParallelMerge() {
if (getConf().getBoolean("hbasefsck.overlap.merge.parallel", true)) {
- LOG.info("Handling overlap merges in parallel; set
hbasefsck.overlap.merge.parallel to" +
+ LOG.trace("Running overlap check in parallel; set
hbasefsck.overlap.merge.parallel to" +
" false to run serially.");
} else {
- LOG.info("Handling overlap merges serially; set
hbasefsck.overlap.merge.parallel to" +
+ LOG.trace("Handling overlap check serially; set
hbasefsck.overlap.merge.parallel to" +
" true to run in parallel.");
}
}
private SortedMap<TableName, TableInfo> checkHdfsIntegrity(boolean fixHoles,
boolean fixOverlaps) throws IOException {
- LOG.info("Checking HBase region split map from HDFS data...");
logParallelMerge();
for (TableInfo tInfo : tablesInfo.values()) {
TableIntegrityErrorHandler handler;
@@ -1993,7 +1988,6 @@ public class HBaseFsck extends Configured implements
Closeable {
* regionInfoMap
*/
public void loadHdfsRegionDirs() throws IOException, InterruptedException {
- LOG.info("Loading HBase regioninfo from HDFS...");
Path rootDir = FSUtils.getRootDir(getConf());
FileSystem fs = rootDir.getFileSystem(getConf());
@@ -2037,7 +2031,6 @@ public class HBaseFsck extends Configured implements
Closeable {
tableDir.getPath(), e.getCause());
}
}
- errors.print("");
}
/**
@@ -3961,7 +3954,6 @@ public class HBaseFsck extends Configured implements
Closeable {
MetaTableAccessor.fullScanRegions(connection, visitor);
}
- errors.print("");
return true;
}
@@ -4461,9 +4453,6 @@ public class HBaseFsck extends Configured implements
Closeable {
@Override
public synchronized void progress() {
if (showProgress++ == progressThreshold) {
- if (!summary) {
- System.out.print(".");
- }
showProgress = 0;
}
}
@@ -4591,7 +4580,7 @@ public class HBaseFsck extends Configured implements
Closeable {
HdfsEntry he = new HdfsEntry();
synchronized (hbi) {
if (hbi.getHdfsRegionDir() != null) {
- errors.print("Directory " + encodedName + " duplicate??" +
+ errors.print("Directory " + encodedName + " duplicate?? " +
hbi.getHdfsRegionDir());
}
diff --git
a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
index 75ad449..a0d530d 100644
---
a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
+++
b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HFileCorruptionChecker.java
@@ -509,20 +509,20 @@ public class HFileCorruptionChecker {
*/
public void report(HBaseFsck.ErrorReporter out) {
out.print("Checked " + hfilesChecked.get() + " hfiles for corruption");
- out.print(" Corrupt HFiles: " + corrupted.size());
+ out.print(" Corrupt HFiles: " + corrupted.size());
if (inQuarantineMode) {
- out.print(" Successfully Quarantined HFiles: " + quarantined.size());
+ out.print(" Successfully Quarantined HFiles: " + quarantined.size());
for (Path sq : quarantined) {
out.print(" " + sq);
}
- out.print(" Failed Quarantine HFiles: " + failures.size());
+ out.print(" Failed Quarantine HFiles: " + failures.size());
for (Path fq : failures) {
- out.print(" " + fq);
+ out.print(" " + fq);
}
}
- out.print(" HFiles moved while checking: " + missing.size());
+ out.print(" HFiles moved while checking: " + missing.size());
for (Path mq : missing) {
- out.print(" " + mq);
+ out.print(" " + mq);
}
String initialState = (corrupted.isEmpty()) ? "OK" : "CORRUPTED";
@@ -530,25 +530,25 @@ public class HFileCorruptionChecker {
: "CORRUPTED";
if (inQuarantineMode) {
- out.print("Summary: " + initialState + " => " + fixedState);
+ out.print("HFile Summary: " + initialState + " => " + fixedState);
} else {
- out.print("Summary: " + initialState);
+ out.print("HFile Summary: " + initialState);
}
// print mob-related report
out.print("Checked " + mobFilesChecked.get() + " MOB files for
corruption");
- out.print(" Corrupt MOB files: " +
corruptedMobFiles.size());
+ out.print(" Corrupt MOB files: " + corruptedMobFiles.size());
if (inQuarantineMode) {
- out.print(" Successfully Quarantined MOB files: " +
quarantinedMobFiles.size());
+ out.print(" Successfully Quarantined MOB files: " +
quarantinedMobFiles.size());
for (Path sq : quarantinedMobFiles) {
- out.print(" " + sq);
+ out.print(" " + sq);
}
- out.print(" Failed Quarantine MOB files: " +
failureMobFiles.size());
+ out.print(" Failed Quarantine MOB files: " +
failureMobFiles.size());
for (Path fq : failureMobFiles) {
- out.print(" " + fq);
+ out.print(" " + fq);
}
}
- out.print(" MOB files moved while checking: " + missedMobFiles.size());
+ out.print(" MOB files moved while checking: " + missedMobFiles.size());
for (Path mq : missedMobFiles) {
out.print(" " + mq);
}
diff --git
a/hbase-hbck2/src/test/java/org/apache/hbase/TestSchedulingRecoveries.java
b/hbase-hbck2/src/test/java/org/apache/hbase/TestSchedulingRecoveries.java
index 08ff118..1ff70c7 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestSchedulingRecoveries.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestSchedulingRecoveries.java
@@ -81,4 +81,4 @@ public class TestSchedulingRecoveries {
}
assertTrue(thrown);
}
-}
+}
\ No newline at end of file