Skip to content

Commit

Permalink
HBASE-23307 Add running of ReplicationBarrierCleaner to hbck2 fixMeta…
Browse files Browse the repository at this point in the history
… invocation (#859)

Signed-off-by: Lijin Bin <binlijin@apache.org>
  • Loading branch information
saintstack committed Nov 22, 2019
1 parent 3b0c276 commit 8e52339
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3869,4 +3869,11 @@ public String getClusterId() {
return cachedClusterId.getFromCacheOrFetch();
}

@Override
public void runReplicationBarrierCleaner() {
ReplicationBarrierCleaner rbc = this.replicationBarrierCleaner;
if (rbc != null) {
rbc.chore();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down Expand Up @@ -122,22 +122,26 @@ protected synchronized void chore() {
LOG.warn("hbckChore is either disabled or is already running. Can't run the chore");
return;
}
running = true;
regionInfoMap.clear();
disabledTableRegions.clear();
splitParentRegions.clear();
orphanRegionsOnRS.clear();
orphanRegionsOnFS.clear();
inconsistentRegions.clear();
checkingStartTimestamp = EnvironmentEdgeManager.currentTime();
loadRegionsFromInMemoryState();
loadRegionsFromRSReport();
running = true;
try {
loadRegionsFromFS();
} catch (IOException e) {
LOG.warn("Failed to load the regions from filesystem", e);
loadRegionsFromInMemoryState();
loadRegionsFromRSReport();
try {
loadRegionsFromFS();
} catch (IOException e) {
LOG.warn("Failed to load the regions from filesystem", e);
}
saveCheckResultToSnapshot();
} catch (Throwable t) {
LOG.warn("Unexpected", t);
}
saveCheckResultToSnapshot();
running = false;
}

Expand Down Expand Up @@ -262,6 +266,10 @@ private void loadRegionsFromFS() throws IOException {
List<Path> regionDirs = FSUtils.getRegionDirs(fs, tableDir);
for (Path regionDir : regionDirs) {
String encodedRegionName = regionDir.getName();
if (encodedRegionName == null) {
LOG.warn("Failed get of encoded name from {}", regionDir);
continue;
}
HbckRegionInfo hri = regionInfoMap.get(encodedRegionName);
if (hri == null) {
orphanRegionsOnFS.put(encodedRegionName, regionDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,4 +537,8 @@ default SplitWALManager getSplitWALManager(){
*/
List<RegionPlan> executeRegionPlansWithThrottling(List<RegionPlan> plans);

/**
* Run the ReplicationBarrierChore.
*/
void runReplicationBarrierCleaner();
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void fix() throws IOException {
}
fixHoles(report);
fixOverlaps(report);
// Run the ReplicationBarrierCleaner here; it may clear out rep_barrier rows which
// can help cleaning up damaged hbase:meta.
this.masterServices.runReplicationBarrierCleaner();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
*/
@InterfaceAudience.Private
public class ReplicationBarrierCleaner extends ScheduledChore {

private static final Logger LOG = LoggerFactory.getLogger(ReplicationBarrierCleaner.class);

private static final String REPLICATION_BARRIER_CLEANER_INTERVAL =
Expand All @@ -71,7 +70,9 @@ public ReplicationBarrierCleaner(Configuration conf, Stoppable stopper, Connecti
}

@Override
protected void chore() {
// Public so can be run out of MasterRpcServices. Synchronized so only one
// running instance at a time.
public synchronized void chore() {
long totalRows = 0;
long cleanedRows = 0;
long deletedRows = 0;
Expand Down Expand Up @@ -168,11 +169,9 @@ protected void chore() {
LOG.warn("Failed to clean up replication barrier", e);
}
if (totalRows > 0) {
LOG.info(
"Cleanup replication barriers: totalRows {}, " +
"cleanedRows {}, deletedRows {}, deletedBarriers {}, deletedLastPushedSeqIds {}",
totalRows, cleanedRows, deletedRows, deletedBarriers, deletedLastPushedSeqIds);
LOG.info("TotalRows={}, cleanedRows={}, deletedRows={}, deletedBarriers={}, " +
"deletedLastPushedSeqIds={}", totalRows, cleanedRows, deletedRows,
deletedBarriers, deletedLastPushedSeqIds);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,7 @@ public List<RegionPlan> executeRegionPlansWithThrottling(List<RegionPlan> plans)
public AsyncClusterConnection getAsyncClusterConnection() {
return null;
}
}

@Override
public void runReplicationBarrierCleaner() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void test() throws Exception {
.filter(p -> (p instanceof ServerCrashProcedure) &&
((ServerCrashProcedure) p).getServerName().equals(SERVER_FOR_TEST)).findAny();
assertTrue("Should have one SCP for " + SERVER_FOR_TEST, procedure.isPresent());
assertFalse("Submit the SCP for the same serverName " + SERVER_FOR_TEST + " which should fail",
assertTrue("Submit the SCP for the same serverName " + SERVER_FOR_TEST + " which should fail",
UTIL.getHBaseCluster().getMaster().getServerManager().expireServer(SERVER_FOR_TEST) ==
Procedure.NO_PROC_ID);

Expand Down

0 comments on commit 8e52339

Please sign in to comment.