Skip to content

Commit 2ff5e55

Browse files
infraioJenkins
authored andcommitted
HBASE-22824 Show filesystem path for the orphans regions on filesystem (apache#469)
Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 549348a) Change-Id: I0807545760cb71e5689b4daaedcff53e85cad961
1 parent 1bdc7dd commit 2ff5e55

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ public class HbckChore extends ScheduledChore {
6161
*/
6262
private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>();
6363

64+
private final Set<String> disabledTableRegions = new HashSet<>();
65+
6466
/**
6567
* The regions only opened on RegionServers, but no region info in meta.
6668
*/
6769
private final Map<String, ServerName> orphanRegionsOnRS = new HashMap<>();
6870
/**
6971
* The regions have directory on FileSystem, but no region info in meta.
7072
*/
71-
private final Set<String> orphanRegionsOnFS = new HashSet<>();
73+
private final Map<String, Path> orphanRegionsOnFS = new HashMap<>();
7274
/**
7375
* The inconsistent regions. There are three case:
7476
* case 1. Master thought this region opened, but no regionserver reported it.
@@ -82,7 +84,7 @@ public class HbckChore extends ScheduledChore {
8284
* The "snapshot" is used to save the last round's HBCK checking report.
8385
*/
8486
private final Map<String, ServerName> orphanRegionsOnRSSnapshot = new HashMap<>();
85-
private final Set<String> orphanRegionsOnFSSnapshot = new HashSet<>();
87+
private final Map<String, Path> orphanRegionsOnFSSnapshot = new HashMap<>();
8688
private final Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegionsSnapshot =
8789
new HashMap<>();
8890

@@ -109,6 +111,7 @@ public HbckChore(MasterServices master) {
109111
protected synchronized void chore() {
110112
running = true;
111113
regionInfoMap.clear();
114+
disabledTableRegions.clear();
112115
orphanRegionsOnRS.clear();
113116
orphanRegionsOnFS.clear();
114117
inconsistentRegions.clear();
@@ -132,7 +135,8 @@ private void saveCheckResultToSnapshot() {
132135
orphanRegionsOnRS.entrySet()
133136
.forEach(e -> orphanRegionsOnRSSnapshot.put(e.getKey(), e.getValue()));
134137
orphanRegionsOnFSSnapshot.clear();
135-
orphanRegionsOnFSSnapshot.addAll(orphanRegionsOnFS);
138+
orphanRegionsOnFS.entrySet()
139+
.forEach(e -> orphanRegionsOnFSSnapshot.put(e.getKey(), e.getValue()));
136140
inconsistentRegionsSnapshot.clear();
137141
inconsistentRegions.entrySet()
138142
.forEach(e -> inconsistentRegionsSnapshot.put(e.getKey(), e.getValue()));
@@ -147,11 +151,9 @@ private void loadRegionsFromInMemoryState() {
147151
master.getAssignmentManager().getRegionStates().getRegionStates();
148152
for (RegionState regionState : regionStates) {
149153
RegionInfo regionInfo = regionState.getRegion();
150-
// Because the inconsistent regions are not absolutely right, only skip the offline regions
151-
// which belong to disabled table.
152154
if (master.getTableStateManager()
153155
.isTableState(regionInfo.getTable(), TableState.State.DISABLED)) {
154-
continue;
156+
disabledTableRegions.add(regionInfo.getEncodedName());
155157
}
156158
HbckRegionInfo.MetaEntry metaEntry =
157159
new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(),
@@ -185,6 +187,11 @@ private void loadRegionsFromRSReport() {
185187
HbckRegionInfo hri = entry.getValue();
186188
ServerName locationInMeta = hri.getMetaEntry().getRegionServer();
187189
if (hri.getDeployedOn().size() == 0) {
190+
// Because the inconsistent regions are not absolutely right, only skip the offline regions
191+
// which belong to disabled table.
192+
if (disabledTableRegions.contains(encodedRegionName)) {
193+
continue;
194+
}
188195
// Master thought this region opened, but no regionserver reported it.
189196
inconsistentRegions.put(encodedRegionName, new Pair<>(locationInMeta, new LinkedList<>()));
190197
} else if (hri.getDeployedOn().size() > 1) {
@@ -209,7 +216,7 @@ private void loadRegionsFromFS() throws IOException {
209216
String encodedRegionName = regionDir.getName();
210217
HbckRegionInfo hri = regionInfoMap.get(encodedRegionName);
211218
if (hri == null) {
212-
orphanRegionsOnFS.add(encodedRegionName);
219+
orphanRegionsOnFS.put(encodedRegionName, regionDir);
213220
continue;
214221
}
215222
HbckRegionInfo.HdfsEntry hdfsEntry = new HbckRegionInfo.HdfsEntry(regionDir);
@@ -244,7 +251,7 @@ public Map<String, ServerName> getOrphanRegionsOnRS() {
244251
/**
245252
* @return the regions have directory on FileSystem, but no region info in meta.
246253
*/
247-
public Set<String> getOrphanRegionsOnFS() {
254+
public Map<String, Path> getOrphanRegionsOnFS() {
248255
// Need synchronized here, as this "snapshot" may be changed after checking.
249256
rwLock.readLock().lock();
250257
try {

hbase-server/src/main/resources/hbase-webapps/master/hbck.jsp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
import="java.util.Date"
2424
import="java.util.List"
2525
import="java.util.Map"
26-
import="java.util.Set"
2726
import="java.util.stream.Collectors"
2827
import="java.time.ZonedDateTime"
2928
import="java.time.format.DateTimeFormatter"
3029
%>
30+
<%@ page import="org.apache.hadoop.fs.Path" %>
31+
<%@ page import="org.apache.hadoop.hbase.client.RegionInfo" %>
3132
<%@ page import="org.apache.hadoop.hbase.master.HbckChore" %>
3233
<%@ page import="org.apache.hadoop.hbase.master.HMaster" %>
3334
<%@ page import="org.apache.hadoop.hbase.ServerName" %>
@@ -42,7 +43,7 @@
4243
HbckChore hbckChore = master.getHbckChore();
4344
Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = null;
4445
Map<String, ServerName> orphanRegionsOnRS = null;
45-
Set<String> orphanRegionsOnFS = null;
46+
Map<String, Path> orphanRegionsOnFS = null;
4647
long startTimestamp = 0;
4748
long endTimestamp = 0;
4849
if (hbckChore != null) {
@@ -106,7 +107,7 @@
106107

107108
<table class="table table-striped">
108109
<tr>
109-
<th>Region</th>
110+
<th>Region Encoded Name</th>
110111
<th>Location in META</th>
111112
<th>Reported Online RegionServers</th>
112113
</tr>
@@ -132,7 +133,7 @@
132133
<% if (orphanRegionsOnRS != null && orphanRegionsOnRS.size() > 0) { %>
133134
<table class="table table-striped">
134135
<tr>
135-
<th>Region</th>
136+
<th>Region Encoded Name</th>
136137
<th>Reported Online RegionServer</th>
137138
</tr>
138139
<% for (Map.Entry<String, ServerName> entry : orphanRegionsOnRS.entrySet()) { %>
@@ -155,11 +156,13 @@
155156
<% if (orphanRegionsOnFS != null && orphanRegionsOnFS.size() > 0) { %>
156157
<table class="table table-striped">
157158
<tr>
158-
<th>Region</th>
159+
<th>Region Encoded Name</th>
160+
<th>FileSystem Path</th>
159161
</tr>
160-
<% for (String region : orphanRegionsOnFS) { %>
162+
<% for (Map.Entry<String, Path> entry : orphanRegionsOnFS.entrySet()) { %>
161163
<tr>
162-
<td><%= region %></td>
164+
<td><%= entry.getKey() %></td>
165+
<td><%= entry.getValue() %></td>
163166
</tr>
164167
<% } %>
165168

hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void testOrphanRegionsOnFS() throws Exception {
192192
HRegion.createRegionDir(conf, regionInfo, FSUtils.getRootDir(conf));
193193
hbckChore.choreForTesting();
194194
assertEquals(1, hbckChore.getOrphanRegionsOnFS().size());
195-
assertTrue(hbckChore.getOrphanRegionsOnFS().contains(regionInfo.getEncodedName()));
195+
assertTrue(hbckChore.getOrphanRegionsOnFS().containsKey(regionInfo.getEncodedName()));
196196

197197
FSUtils.deleteRegionDir(conf, new HRegionInfo(regionInfo));
198198
hbckChore.choreForTesting();

0 commit comments

Comments
 (0)