Skip to content

Commit

Permalink
HBASE-28935 [HBCK2] filesystem command always report region hole and …
Browse files Browse the repository at this point in the history
…doesn't exit automatically (#147)

Co-authored-by: haosenchen <[email protected]>
  • Loading branch information
haosenchen and haosenchen authored Nov 19, 2024
1 parent f69bcbb commit fd5a5fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ int fsck(List<String> tables, boolean fix) throws IOException {
* hbaseFsck.setFixHdfsOrphans(fix); hbaseFsck.setFixHdfsHoles(fix);
* hbaseFsck.setFixHdfsOverlaps(fix); hbaseFsck.setFixTableOrphans(fix);
*/
if (!tables.isEmpty()) {
tables.stream().map(TableName::valueOf).forEach(hbaseFsck::includeTable);
}
if (!tableDirs.isEmpty()) {
tableDirs.forEach(hbaseFsck::includeTableDir);
}
hbaseFsck.offlineHbck();
} catch (ClassNotFoundException | InterruptedException e) {
throw new IOException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public HBaseFsck(Configuration conf) throws IOException, ClassNotFoundException
private static ExecutorService createThreadPool(Configuration conf) {
int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
return new ScheduledThreadPoolExecutor(numThreads,
new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d")
new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d").setDaemon(true)
.setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
}

Expand Down Expand Up @@ -4990,6 +4990,10 @@ Set<TableName> getIncludedTables() {
return new HashSet<>(tablesIncluded);
}

public void includeTableDir(Path tableDir) {
tableDirs.add(tableDir);
}

/**
* We are interested in only those tables that have not changed their state in hbase:meta during
* the last few seconds specified by hbase.admin.fsck.timelag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import java.io.PrintStream;
import java.util.Properties;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -61,6 +64,10 @@ public static void afterClass() throws Exception {
@Before
public void before() throws Exception {
this.hbck2 = new HBCK2(TEST_UTIL.getConfiguration());
if (!TEST_UTIL.getAdmin().tableExists(TableName.valueOf("table"))) {
TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf("table"))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).build());
}
}

@Test
Expand Down

0 comments on commit fd5a5fb

Please sign in to comment.