HBASE-10955 HBCK leaves the region in masters in-memory RegionStates if region hdfs dir is lost
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1587772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9fcb2ae865
commit
585a4f7778
|
@ -516,6 +516,7 @@ public class HBaseFsck extends Configured {
|
||||||
public byte [] metaLastKey;
|
public byte [] metaLastKey;
|
||||||
public byte [] storesFirstKey;
|
public byte [] storesFirstKey;
|
||||||
public byte [] storesLastKey;
|
public byte [] storesLastKey;
|
||||||
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return "regionName=" + Bytes.toStringBinary(regionName) +
|
return "regionName=" + Bytes.toStringBinary(regionName) +
|
||||||
"\nmetaFirstKey=" + Bytes.toStringBinary(metaFirstKey) +
|
"\nmetaFirstKey=" + Bytes.toStringBinary(metaFirstKey) +
|
||||||
|
@ -1864,7 +1865,7 @@ public class HBaseFsck extends Configured {
|
||||||
// these problems from META.
|
// these problems from META.
|
||||||
if (shouldFixAssignments()) {
|
if (shouldFixAssignments()) {
|
||||||
errors.print("Trying to fix unassigned region...");
|
errors.print("Trying to fix unassigned region...");
|
||||||
closeRegion(hbi);// Close region will cause RS to abort.
|
undeployRegions(hbi);
|
||||||
}
|
}
|
||||||
if (shouldFixMeta()) {
|
if (shouldFixMeta()) {
|
||||||
// wait for it to complete
|
// wait for it to complete
|
||||||
|
@ -2317,7 +2318,7 @@ public class HBaseFsck extends Configured {
|
||||||
HTableDescriptor htd = getTableInfo().getHTD();
|
HTableDescriptor htd = getTableInfo().getHTD();
|
||||||
HRegionInfo newRegion = new HRegionInfo(htd.getTableName(), holeStartKey, holeStopKey);
|
HRegionInfo newRegion = new HRegionInfo(htd.getTableName(), holeStartKey, holeStopKey);
|
||||||
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
|
HRegion region = HBaseFsckRepair.createHDFSRegionDir(conf, newRegion, htd);
|
||||||
LOG.info("Plugged hold by creating new empty region: "+ newRegion + " " +region);
|
LOG.info("Plugged hole by creating new empty region: "+ newRegion + " " +region);
|
||||||
fixes++;
|
fixes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.apache.hadoop.hbase.master.RegionState;
|
||||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
|
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,12 +186,10 @@ public class HBaseFsckRepair {
|
||||||
HRegionInfo hri, HTableDescriptor htd) throws IOException {
|
HRegionInfo hri, HTableDescriptor htd) throws IOException {
|
||||||
// Create HRegion
|
// Create HRegion
|
||||||
Path root = FSUtils.getRootDir(conf);
|
Path root = FSUtils.getRootDir(conf);
|
||||||
HRegion region = HRegion.createHRegion(hri, root, conf, htd);
|
HRegion region = HRegion.createHRegion(hri, root, conf, htd, null);
|
||||||
HLog hlog = region.getLog();
|
|
||||||
|
|
||||||
// Close the new region to flush to disk. Close log file too.
|
// Close the new region to flush to disk. Close log file too.
|
||||||
region.close();
|
region.close();
|
||||||
hlog.closeAndDelete();
|
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1481,6 +1481,34 @@ public class TestHBaseFsck {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This creates and fixes a bad table with a missing region which is the 1st region -- hole in
|
||||||
|
* meta and data missing in the fs.
|
||||||
|
*/
|
||||||
|
@Test(timeout=120000)
|
||||||
|
public void testRegionDeployedNotInHdfs() throws Exception {
|
||||||
|
TableName table =
|
||||||
|
TableName.valueOf("testSingleRegionDeployedNotInHdfs");
|
||||||
|
try {
|
||||||
|
setupTable(table);
|
||||||
|
TEST_UTIL.getHBaseAdmin().flush(table.getName());
|
||||||
|
|
||||||
|
// Mess it up by deleting region dir
|
||||||
|
deleteRegion(conf, tbl.getTableDescriptor(),
|
||||||
|
HConstants.EMPTY_START_ROW, Bytes.toBytes("A"), false,
|
||||||
|
false, true);
|
||||||
|
|
||||||
|
HBaseFsck hbck = doFsck(conf, false);
|
||||||
|
assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.NOT_IN_HDFS });
|
||||||
|
// fix hole
|
||||||
|
doFsck(conf, true);
|
||||||
|
// check that hole fixed
|
||||||
|
assertNoErrors(doFsck(conf, false));
|
||||||
|
} finally {
|
||||||
|
deleteTable(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates and fixes a bad table with missing last region -- hole in meta and data missing in
|
* This creates and fixes a bad table with missing last region -- hole in meta and data missing in
|
||||||
* the fs.
|
* the fs.
|
||||||
|
|
Loading…
Reference in New Issue