Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-27862:HMaster.getCompactionState's return result about table compaction state is not quite right #5235

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4142,6 +4142,7 @@ public RSGroupInfoManager getRSGroupInfoManager() {
*/
public CompactionState getCompactionState(final TableName tableName) {
CompactionState compactionState = CompactionState.NONE;
List<String> notOnlineRegions = new ArrayList<>();
try {
List<RegionInfo> regions = assignmentManager.getRegionStates().getRegionsOfTable(tableName);
for (RegionInfo regionInfo : regions) {
Expand All @@ -4155,6 +4156,13 @@ public CompactionState getCompactionState(final TableName tableName) {
continue;
}
RegionMetrics regionMetrics = sl.getRegionMetrics().get(regionInfo.getRegionName());
if (regionMetrics == null) {
String regionName = regionInfo.getRegionNameAsString();
LOG.error("Can not get compaction details for the region: " + regionName +
" , it may be disabled or in transition.");
notOnlineRegions.add(regionName);
continue;
}
if (regionMetrics.getCompactionState() == CompactionState.MAJOR) {
if (compactionState == CompactionState.MINOR) {
compactionState = CompactionState.MAJOR_AND_MINOR;
Expand All @@ -4169,6 +4177,9 @@ public CompactionState getCompactionState(final TableName tableName) {
}
}
}
if (notOnlineRegions.size() > 0 && compactionState == CompactionState.NONE) {
compactionState = null;
}
} catch (Exception e) {
compactionState = null;
LOG.error("Exception when get compaction state for " + tableName.getNameAsString(), e);
Expand Down