Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ public int onlineConsistencyRepair() throws IOException, KeeperException, Interr
loadDeployedRegions();
// check whether hbase:meta is deployed and online
recordMetaRegion();
// Report inconsistencies if there are any unknown servers.
reportUnknownServers();
// Check if hbase:meta is found only once and in the right place
if (!checkMetaRegion()) {
String errorMsg = "hbase:meta table is not consistent. ";
Expand Down Expand Up @@ -707,6 +709,18 @@ public int onlineConsistencyRepair() throws IOException, KeeperException, Interr
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
* exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ enum ERROR_CODE {
UNDELETED_REPLICATION_QUEUE,
DUPE_ENDKEYS,
UNSUPPORTED_OPTION,
INVALID_TABLE
INVALID_TABLE,
UNKNOWN_SERVER
}

void clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
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.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
Expand Down Expand Up @@ -552,4 +555,23 @@ public void testOnlineChangeTableSchema() throws IOException, InterruptedExcepti
ADMIN.listTableDescriptors();
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());
}
}