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-27859:HMaster.getCompactionState can happen NPE when region state is closed #5232

Merged
merged 5 commits into from
Jul 6, 2023
Merged
Changes from 4 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 @@ -4155,6 +4155,12 @@ public CompactionState getCompactionState(final TableName tableName) {
continue;
}
RegionMetrics regionMetrics = sl.getRegionMetrics().get(regionInfo.getRegionName());
if (regionMetrics == null) {
LOG.warn(String.format(
"Can not get compaction details for the region: %s , it may be not online.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log4j already has the parameterised feature, there's no need to use String.format here. Just do:

LOG.warn("Can not get compaction details for the region: {} , it may be not online.", regionInfo.getRegionNameAsString());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update has been made, thanks

regionInfo.getRegionNameAsString()));
continue;
}
if (regionMetrics.getCompactionState() == CompactionState.MAJOR) {
if (compactionState == CompactionState.MINOR) {
compactionState = CompactionState.MAJOR_AND_MINOR;
Expand Down