@InterfaceAudience.LimitedPrivate(value="Tools") @InterfaceStability.Evolving public class HBaseFsck extends Configured implements Closeable
Region consistency checks verify that hbase:meta, region deployment on region servers and the state of data in HDFS (.regioninfo files) all are in accordance.
Table integrity checks verify that all possible row keys resolve to exactly one region of a table. This means there are no individual degenerate or backwards regions; no holes between regions; and that there are no overlapping regions.
The general repair strategy works in two phases:
For table integrity repairs, the tables' region directories are scanned for .regioninfo files. Each table's integrity is then verified. If there are any orphan regions (regions with no .regioninfo files) or holes, new regions are fabricated. Backwards regions are sidelined as well as empty degenerate (endkey==startkey) regions. If there are any overlapping regions, a new region is created and all data is merged into the new region.
Table integrity repairs deal solely with HDFS and could potentially be done offline -- the hbase region servers or master do not need to be running. This phase can eventually be used to completely reconstruct the hbase:meta table in an offline fashion.
Region consistency requires three conditions -- 1) valid .regioninfo file present in an HDFS region dir, 2) valid row with .regioninfo data in META, and 3) a region is deployed only at the regionserver that was assigned to with proper state in the master.
Region consistency repairs require hbase to be online so that hbck can contact the HBase master and region servers. The hbck#connect() method must first be called successfully. Much of the region consistency information is transient and less risky to repair.
If hbck is run from the command line, there are a handful of arguments that
can be used to limit the kinds of repairs hbck will do. See the code in
printUsageAndExit()
for more details.
Modifier and Type | Class and Description |
---|---|
static interface |
HBaseFsck.ErrorReporter |
static class |
HBaseFsck.HbckInfo
Maintain information about a particular region.
|
static class |
HBaseFsck.RegionRepairException
Exception thrown when a integrity repair operation fails in an
unresolvable way.
|
class |
HBaseFsck.TableInfo
Maintain information about a particular table.
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_SLEEP_BEFORE_RERUN |
static long |
DEFAULT_TIME_LAG |
protected ExecutorService |
executor |
Constructor and Description |
---|
HBaseFsck(Configuration conf)
Constructor
|
HBaseFsck(Configuration conf,
ExecutorService exec)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
checkRegionBoundaries() |
void |
close() |
void |
connect()
To repair region consistency, one must call connect() in order to repair
online state.
|
protected HFileCorruptionChecker |
createHFileCorruptionChecker(boolean sidelineCorruptHFiles) |
static void |
debugLsr(Configuration conf,
Path p)
ls -r for debugging purposes
|
static void |
debugLsr(Configuration conf,
Path p,
HBaseFsck.ErrorReporter errors)
ls -r for debugging purposes
|
void |
dumpOverlapProblems(<any> regions) |
void |
dumpSidelinedRegions(Map<Path,HBaseFsck.HbckInfo> regions) |
HBaseFsck |
exec(ExecutorService exec,
String[] args) |
void |
fixEmptyMetaCells()
To fix the empty REGIONINFO_QUALIFIER rows from hbase:meta
|
void |
fixOrphanTables()
To fix orphan table by creating a .tableinfo file under tableDir
1. |
HBaseFsck.ErrorReporter |
getErrors() |
HFileCorruptionChecker |
getHFilecorruptionChecker() |
int |
getMaxMerge() |
int |
getMaxOverlapsToSideline() |
<any> |
getOverlapGroups(TableName table) |
int |
getRetCode() |
void |
includeTable(TableName table) |
static byte[] |
keyOnly(byte[] b) |
void |
loadHdfsRegionDirs()
Scan HDFS for all regions, recording their information into
regionInfoMap
|
static void |
main(String[] args)
Main program
|
int |
mergeRegionDirs(Path targetRegionDir,
HBaseFsck.HbckInfo contained)
Merge hdfs data by moving from contained HbckInfo into targetRegionDir.
|
void |
offlineHdfsIntegrityRepair()
This repair method analyzes hbase data in hdfs and repairs it to satisfy
the table integrity rules.
|
int |
onlineConsistencyRepair()
This repair method requires the cluster to be online since it contacts
region servers and the masters.
|
int |
onlineHbck()
Contacts the master and prints out cluster-wide information
|
protected HBaseFsck |
printUsageAndExit() |
boolean |
rebuildMeta(boolean fix)
Rebuilds meta from information in hdfs/fs.
|
void |
setCheckHdfs(boolean checking) |
static void |
setDisplayFullReport()
Display the full report from fsck.
|
void |
setFixAssignments(boolean shouldFix)
Fix inconsistencies found by fsck.
|
void |
setFixEmptyMetaCells(boolean shouldFix) |
void |
setFixHdfsHoles(boolean shouldFix) |
void |
setFixHdfsOrphans(boolean shouldFix) |
void |
setFixHdfsOverlaps(boolean shouldFix) |
void |
setFixMeta(boolean shouldFix) |
void |
setFixReferenceFiles(boolean shouldFix) |
void |
setFixSplitParents(boolean shouldFix) |
void |
setFixTableLocks(boolean shouldFix)
Set table locks fix mode.
|
void |
setFixTableOrphans(boolean shouldFix) |
void |
setFixTableZNodes(boolean shouldFix)
Set orphaned table ZNodes fix mode.
|
void |
setFixVersionFile(boolean shouldFix) |
void |
setHFileCorruptionChecker(HFileCorruptionChecker hfcc) |
void |
setIgnorePreCheckPermission(boolean ignorePreCheckPermission) |
void |
setMaxMerge(int mm) |
void |
setMaxOverlapsToSideline(int mo) |
void |
setRetCode(int code) |
void |
setSidelineBigOverlaps(boolean sbo) |
void |
setSidelineDir(String sidelineDir) |
void |
setTimeLag(long seconds)
We are interested in only those tables that have not changed their state in
hbase:meta during the last few seconds specified by hbase.admin.fsck.timelag
|
boolean |
shouldFixVersionFile() |
boolean |
shouldIgnorePreCheckPermission() |
boolean |
shouldSidelineBigOverlaps() |
public static final long DEFAULT_TIME_LAG
public static final long DEFAULT_SLEEP_BEFORE_RERUN
protected ExecutorService executor
public HBaseFsck(Configuration conf) throws MasterNotRunningException, ZooKeeperConnectionException, IOException, ClassNotFoundException
conf
- Configuration objectMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to ZooKeeperIOException
ClassNotFoundException
public HBaseFsck(Configuration conf, ExecutorService exec) throws MasterNotRunningException, ZooKeeperConnectionException, IOException, ClassNotFoundException
conf
- Configuration objectMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to ZooKeeperIOException
ClassNotFoundException
public void connect() throws IOException
IOException
public void offlineHdfsIntegrityRepair() throws IOException, InterruptedException
IOException
InterruptedException
public int onlineConsistencyRepair() throws IOException, KeeperException, InterruptedException
IOException
KeeperException
InterruptedException
public int onlineHbck() throws IOException, KeeperException, InterruptedException, ServiceException
IOException
KeeperException
InterruptedException
ServiceException
public static byte[] keyOnly(byte[] b)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void checkRegionBoundaries()
public HBaseFsck.ErrorReporter getErrors()
public void fixEmptyMetaCells() throws IOException
IOException
public void fixOrphanTables() throws IOException
HTableDescriptor
and HColumnDescriptor
IOException
public boolean rebuildMeta(boolean fix) throws IOException, InterruptedException
fix
- flag that determines if method should attempt to fix holesIOException
InterruptedException
public void loadHdfsRegionDirs() throws IOException, InterruptedException
IOException
InterruptedException
public int mergeRegionDirs(Path targetRegionDir, HBaseFsck.HbckInfo contained) throws IOException
IOException
public void dumpOverlapProblems(<any> regions)
public void dumpSidelinedRegions(Map<Path,HBaseFsck.HbckInfo> regions)
public <any> getOverlapGroups(TableName table)
public static void setDisplayFullReport()
public void setFixTableLocks(boolean shouldFix)
public void setFixTableZNodes(boolean shouldFix)
public void setFixAssignments(boolean shouldFix)
public void setFixMeta(boolean shouldFix)
public void setFixEmptyMetaCells(boolean shouldFix)
public void setCheckHdfs(boolean checking)
public void setFixHdfsHoles(boolean shouldFix)
public void setFixTableOrphans(boolean shouldFix)
public void setFixHdfsOverlaps(boolean shouldFix)
public void setFixHdfsOrphans(boolean shouldFix)
public void setFixVersionFile(boolean shouldFix)
public boolean shouldFixVersionFile()
public void setSidelineBigOverlaps(boolean sbo)
public boolean shouldSidelineBigOverlaps()
public void setFixSplitParents(boolean shouldFix)
public void setFixReferenceFiles(boolean shouldFix)
public boolean shouldIgnorePreCheckPermission()
public void setIgnorePreCheckPermission(boolean ignorePreCheckPermission)
public void setMaxMerge(int mm)
mm
- maximum number of regions to merge into a single region.public int getMaxMerge()
public void setMaxOverlapsToSideline(int mo)
public int getMaxOverlapsToSideline()
public void includeTable(TableName table)
public void setTimeLag(long seconds)
seconds
- - the time in secondspublic void setSidelineDir(String sidelineDir)
sidelineDir
- - HDFS path to sideline dataprotected HFileCorruptionChecker createHFileCorruptionChecker(boolean sidelineCorruptHFiles) throws IOException
IOException
public HFileCorruptionChecker getHFilecorruptionChecker()
public void setHFileCorruptionChecker(HFileCorruptionChecker hfcc)
public void setRetCode(int code)
public int getRetCode()
protected HBaseFsck printUsageAndExit()
public static void main(String[] args) throws Exception
args
- Exception
public HBaseFsck exec(ExecutorService exec, String[] args) throws KeeperException, IOException, ServiceException, InterruptedException
KeeperException
IOException
ServiceException
InterruptedException
public static void debugLsr(Configuration conf, Path p) throws IOException
IOException
public static void debugLsr(Configuration conf, Path p, HBaseFsck.ErrorReporter errors) throws IOException
IOException