HBASE-27793 Make HBCK be able to report unknown servers (#5229)
Co-authored-by: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
This commit is contained in:
parent
bc64a1bc99
commit
be5b219595
hbase-server/src
main/java/org/apache/hadoop/hbase/util
test/java/org/apache/hadoop/hbase/client
@ -657,6 +657,8 @@ public class HBaseFsck extends Configured implements Closeable {
|
|||||||
loadDeployedRegions();
|
loadDeployedRegions();
|
||||||
// check whether hbase:meta is deployed and online
|
// check whether hbase:meta is deployed and online
|
||||||
recordMetaRegion();
|
recordMetaRegion();
|
||||||
|
// Report inconsistencies if there are any unknown servers.
|
||||||
|
reportUnknownServers();
|
||||||
// Check if hbase:meta is found only once and in the right place
|
// Check if hbase:meta is found only once and in the right place
|
||||||
if (!checkMetaRegion()) {
|
if (!checkMetaRegion()) {
|
||||||
String errorMsg = "hbase:meta table is not consistent. ";
|
String errorMsg = "hbase:meta table is not consistent. ";
|
||||||
@ -709,6 +711,18 @@ public class HBaseFsck extends Configured implements Closeable {
|
|||||||
return errors.getErrorList().size();
|
return errors.getErrorList().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reportUnknownServers() throws IOException {
|
||||||
|
List<ServerName> unknownServers = admin.listUnknownServers();
|
||||||
|
if (!unknownServers.isEmpty()) {
|
||||||
|
unknownServers.stream().forEach(serverName -> {
|
||||||
|
errors.reportError(ERROR_CODE.UNKNOWN_SERVER,
|
||||||
|
"Found unknown server,"
|
||||||
|
+ "some of the regions held by this server may not get assigned. "
|
||||||
|
+ String.format("Use HBCK2 scheduleRecoveries %s to recover.", serverName));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method maintains an ephemeral znode. If the creation fails we return false or throw
|
* This method maintains an ephemeral znode. If the creation fails we return false or throw
|
||||||
* exception
|
* exception
|
||||||
|
@ -65,7 +65,8 @@ public interface HbckErrorReporter {
|
|||||||
UNDELETED_REPLICATION_QUEUE,
|
UNDELETED_REPLICATION_QUEUE,
|
||||||
DUPE_ENDKEYS,
|
DUPE_ENDKEYS,
|
||||||
UNSUPPORTED_OPTION,
|
UNSUPPORTED_OPTION,
|
||||||
INVALID_TABLE
|
INVALID_TABLE,
|
||||||
|
UNKNOWN_SERVER
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -40,6 +40,9 @@ import org.apache.hadoop.hbase.TableExistsException;
|
|||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.hadoop.hbase.master.LoadBalancer;
|
import org.apache.hadoop.hbase.master.LoadBalancer;
|
||||||
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
|
import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
|
||||||
|
import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
|
||||||
import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory;
|
import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory;
|
||||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||||
@ -551,4 +554,23 @@ public class TestAdmin extends TestAdminBase {
|
|||||||
ADMIN.listTableDescriptors();
|
ADMIN.listTableDescriptors();
|
||||||
assertFalse(ADMIN.tableExists(tableName));
|
assertFalse(ADMIN.tableExists(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUnknownServers() throws Exception {
|
||||||
|
TableName table = TableName.valueOf(name.getMethodName());
|
||||||
|
ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY);
|
||||||
|
ADMIN.createTable(TableDescriptorBuilder.newBuilder(table).setColumnFamily(cfd).build());
|
||||||
|
final List<RegionInfo> regions = ADMIN.getRegions(table);
|
||||||
|
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
|
||||||
|
final AssignmentManager am = master.getAssignmentManager();
|
||||||
|
RegionStateNode rsNode = am.getRegionStates().getRegionStateNode(regions.get(0));
|
||||||
|
ServerName regionLocation = rsNode.getRegionLocation();
|
||||||
|
rsNode.setRegionLocation(ServerName.valueOf("dummyserver", 1234, System.currentTimeMillis()));
|
||||||
|
try {
|
||||||
|
assertTrue(ADMIN.listUnknownServers().get(0).getHostname().equals("dummyserver"));
|
||||||
|
} finally {
|
||||||
|
rsNode.setRegionLocation(regionLocation);
|
||||||
|
}
|
||||||
|
assertTrue(ADMIN.listUnknownServers().isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user