Skip to content

Commit fd5a5fb

Browse files
haosenchenhaosenchen
and
haosenchen
authored
HBASE-28935 [HBCK2] filesystem command always report region hole and doesn't exit automatically (#147)
Co-authored-by: haosenchen <[email protected]>
1 parent f69bcbb commit fd5a5fb

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ int fsck(List<String> tables, boolean fix) throws IOException {
7777
* hbaseFsck.setFixHdfsOrphans(fix); hbaseFsck.setFixHdfsHoles(fix);
7878
* hbaseFsck.setFixHdfsOverlaps(fix); hbaseFsck.setFixTableOrphans(fix);
7979
*/
80+
if (!tables.isEmpty()) {
81+
tables.stream().map(TableName::valueOf).forEach(hbaseFsck::includeTable);
82+
}
83+
if (!tableDirs.isEmpty()) {
84+
tableDirs.forEach(hbaseFsck::includeTableDir);
85+
}
8086
hbaseFsck.offlineHbck();
8187
} catch (ClassNotFoundException | InterruptedException e) {
8288
throw new IOException(e);

Diff for: hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public HBaseFsck(Configuration conf) throws IOException, ClassNotFoundException
374374
private static ExecutorService createThreadPool(Configuration conf) {
375375
int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
376376
return new ScheduledThreadPoolExecutor(numThreads,
377-
new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d")
377+
new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d").setDaemon(true)
378378
.setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
379379
}
380380

@@ -4990,6 +4990,10 @@ Set<TableName> getIncludedTables() {
49904990
return new HashSet<>(tablesIncluded);
49914991
}
49924992

4993+
public void includeTableDir(Path tableDir) {
4994+
tableDirs.add(tableDir);
4995+
}
4996+
49934997
/**
49944998
* We are interested in only those tables that have not changed their state in hbase:meta during
49954999
* the last few seconds specified by hbase.admin.fsck.timelag

Diff for: hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import java.io.PrintStream;
3333
import java.util.Properties;
3434
import org.apache.hadoop.hbase.HBaseTestingUtility;
35+
import org.apache.hadoop.hbase.TableName;
36+
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
37+
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
3538
import org.junit.AfterClass;
3639
import org.junit.Before;
3740
import org.junit.BeforeClass;
@@ -61,6 +64,10 @@ public static void afterClass() throws Exception {
6164
@Before
6265
public void before() throws Exception {
6366
this.hbck2 = new HBCK2(TEST_UTIL.getConfiguration());
67+
if (!TEST_UTIL.getAdmin().tableExists(TableName.valueOf("table"))) {
68+
TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf("table"))
69+
.setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).build());
70+
}
6471
}
6572

6673
@Test

0 commit comments

Comments
 (0)