HBASE-22808 HBCK Report showed the offline regions which belong to disabled table (#465)

Signed-off-by: Stack <stack@apache.org>
This commit is contained in:
Guanghao Zhang 2019-08-08 03:57:17 -05:00 committed by GitHub
parent 0e5dc6d7ce
commit 9250977681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 1 deletions

View File

@ -672,6 +672,10 @@ public class CatalogJanitor extends ScheduledChore {
if (sn == null) {
continue;
}
// skip the offline regions which belong to disabled table.
if (isTableDisabled(location.getRegion())) {
continue;
}
ServerManager.ServerLiveState state = this.services.getServerManager().
isServerKnownAndOnline(sn);
switch (state) {

View File

@ -31,6 +31,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ScheduledChore;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.HbckRegionInfo;
@ -146,6 +147,12 @@ public class HbckChore extends ScheduledChore {
master.getAssignmentManager().getRegionStates().getRegionStates();
for (RegionState regionState : regionStates) {
RegionInfo regionInfo = regionState.getRegion();
// Because the inconsistent regions are not absolutely right, only skip the offline regions
// which belong to disabled table.
if (master.getTableStateManager()
.isTableState(regionInfo.getTable(), TableState.State.DISABLED)) {
continue;
}
HbckRegionInfo.MetaEntry metaEntry =
new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(),
regionState.getStamp());

View File

@ -33,7 +33,9 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.master.HbckChore;
import org.apache.hadoop.hbase.master.TableStateManager;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
@ -43,6 +45,7 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -139,13 +142,44 @@ public class TestHbckChore extends TestAssignmentManagerBase {
assertTrue(reportedRegionServers.contains(locationInMeta));
assertTrue(reportedRegionServers.contains(anotherServer));
// Reported right region location. Then not in problematic regions.
// Reported right region location, then not in inconsistent regions.
am.reportOnlineRegions(anotherServer, Collections.EMPTY_SET);
hbckChore.choreForTesting();
inconsistentRegions = hbckChore.getInconsistentRegions();
assertFalse(inconsistentRegions.containsKey(regionName));
}
@Test
public void testForDisabledTable() throws Exception {
TableName tableName = TableName.valueOf("testForDisabledTable");
RegionInfo hri = createRegionInfo(tableName, 1);
String regionName = hri.getEncodedName();
rsDispatcher.setMockRsExecutor(new GoodRsExecutor());
Future<byte[]> future = submitProcedure(createAssignProcedure(hri));
waitOnFuture(future);
List<ServerName> serverNames = master.getServerManager().getOnlineServersList();
assertEquals(NSERVERS, serverNames.size());
hbckChore.choreForTesting();
Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions =
hbckChore.getInconsistentRegions();
assertTrue(inconsistentRegions.containsKey(regionName));
Pair<ServerName, List<ServerName>> pair = inconsistentRegions.get(regionName);
ServerName locationInMeta = pair.getFirst();
List<ServerName> reportedRegionServers = pair.getSecond();
assertTrue(serverNames.contains(locationInMeta));
assertEquals(0, reportedRegionServers.size());
// Set table state to disabled, then not in inconsistent regions.
TableStateManager tableStateManager = master.getTableStateManager();
Mockito.when(tableStateManager.isTableState(tableName, TableState.State.DISABLED)).
thenReturn(true);
hbckChore.choreForTesting();
inconsistentRegions = hbckChore.getInconsistentRegions();
assertFalse(inconsistentRegions.containsKey(regionName));
}
@Test
public void testOrphanRegionsOnFS() throws Exception {
TableName tableName = TableName.valueOf("testOrphanRegionsOnFS");