Skip to content
Open
Show file tree
Hide file tree
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 @@ -4246,6 +4246,7 @@ public void remoteProcedureFailed(long procId, RemoteProcedureException error) {
* @return procedure Id
* @throws IOException if reopening region fails while running procedure
*/
@Deprecated
long reopenRegions(final TableName tableName, final List<byte[]> regionNames,
final long nonceGroup, final long nonce) throws IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class RegionsRecoveryChore extends ScheduledChore {

private static final String REGIONS_RECOVERY_CHORE_NAME = "RegionsRecoveryChore";

private static final String ERROR_REOPEN_REIONS_MSG =
"Error reopening regions with high storeRefCount. ";
private static final String ERROR_REOPEN_REGIONS_MSG =
"Error reopening regions with high storeRefCount.";

private final HMaster hMaster;
private final int storeFileRefCountThreshold;
Expand All @@ -73,7 +73,6 @@ public class RegionsRecoveryChore extends ScheduledChore {
this.hMaster = hMaster;
this.storeFileRefCountThreshold = configuration.getInt(
HConstants.STORE_FILE_REF_COUNT_THRESHOLD, HConstants.DEFAULT_STORE_FILE_REF_COUNT_THRESHOLD);

}

@Override
Expand All @@ -94,11 +93,11 @@ protected void chore() {
tableToReopenRegionsMap.forEach((tableName, regionNames) -> {
try {
LOG.warn("Reopening regions due to high storeFileRefCount. "
+ "TableName: {} , noOfRegions: {}", tableName, regionNames.size());
hMaster.reopenRegions(tableName, regionNames, NONCE_GENERATOR.getNonceGroup(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't really comment on whether it's a good idea to throttle these reopens since I don't have enough context on this code path.

Copy link
Contributor Author

@liuxiaocs7 liuxiaocs7 Mar 2, 2026

Choose a reason for hiding this comment

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

Hi, @charlesconnell, thanks for your comments, RegionsRecoveryChore used to reopen region whose maxCompactedStoreFileRefCount metric large than the configured storeFileRefCountThreshold, if throttle feature is enabled, we can avoid reopen them at the same time. At the same time, the default behavior will remain consistent with previous

NONCE_GENERATOR.newNonce());
+ "TableName: {}, numOfRegions: {}", tableName, regionNames.size());
hMaster.reopenRegionsThrottled(tableName, regionNames,
NONCE_GENERATOR.getNonceGroup(), NONCE_GENERATOR.newNonce());
} catch (IOException e) {
LOG.error("{} tableName: {}, regionNames: {}", ERROR_REOPEN_REIONS_MSG, tableName,
LOG.error("{} tableName: {}, regionNames: {}", ERROR_REOPEN_REGIONS_MSG, tableName,
regionNames, e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hadoop.hbase.UnknownRegionException;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.conf.ConfigKey;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
import org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure;
import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ServerMetrics;
Expand All @@ -45,25 +44,21 @@
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Test for RegionsRecoveryChore
*/
@Category({ MasterTests.class, SmallTests.class })
@Tag(MasterTests.TAG)
@Tag(SmallTests.TAG)
public class TestRegionsRecoveryChore {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRegionsRecoveryChore.class);

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

private static final HBaseTestingUtil HBASE_TESTING_UTILITY = new HBaseTestingUtil();
Expand Down Expand Up @@ -96,13 +91,13 @@ private Configuration getCustomConf() {
return conf;
}

@Before
@BeforeEach
public void setUp() throws Exception {
this.hMaster = Mockito.mock(HMaster.class);
this.assignmentManager = Mockito.mock(AssignmentManager.class);
}

@After
@AfterEach
public void tearDown() throws Exception {
Mockito.verifyNoMoreInteractions(this.hMaster);
Mockito.verifyNoMoreInteractions(this.assignmentManager);
Expand Down Expand Up @@ -134,8 +129,8 @@ public void testRegionReopensWithStoreRefConfig() throws Exception {
regionsRecoveryChore.chore();

// Verify that we need to reopen regions of 2 tables
Mockito.verify(hMaster, Mockito.times(2)).reopenRegions(Mockito.any(), Mockito.anyList(),
Mockito.anyLong(), Mockito.anyLong());
Mockito.verify(hMaster, Mockito.times(2)).reopenRegionsThrottled(Mockito.any(),
Mockito.anyList(), Mockito.anyLong(), Mockito.anyLong());
Mockito.verify(hMaster, Mockito.times(1)).getClusterMetrics();

// Verify that we need to reopen total 3 regions that have refCount > 300
Expand Down Expand Up @@ -169,8 +164,8 @@ public void testRegionReopensWithLessThreshold() throws Exception {
regionsRecoveryChore.chore();

// Verify that we need to reopen regions of only 1 table
Mockito.verify(hMaster, Mockito.times(1)).reopenRegions(Mockito.any(), Mockito.anyList(),
Mockito.anyLong(), Mockito.anyLong());
Mockito.verify(hMaster, Mockito.times(1)).reopenRegionsThrottled(Mockito.any(),
Mockito.anyList(), Mockito.anyLong(), Mockito.anyLong());
Mockito.verify(hMaster, Mockito.times(1)).getClusterMetrics();

// Verify that we need to reopen only 1 region with refCount > 400
Expand Down Expand Up @@ -205,8 +200,8 @@ public void testRegionReopensWithoutStoreRefConfig() throws Exception {

// Verify that by default the feature is turned off so no regions
// should be reopened
Mockito.verify(hMaster, Mockito.times(0)).reopenRegions(Mockito.any(), Mockito.anyList(),
Mockito.anyLong(), Mockito.anyLong());
Mockito.verify(hMaster, Mockito.times(0)).reopenRegionsThrottled(Mockito.any(),
Mockito.anyList(), Mockito.anyLong(), Mockito.anyLong());

// default maxCompactedStoreFileRefCount is -1 (no regions to be reopened using AM)
Mockito.verify(hMaster, Mockito.times(0)).getAssignmentManager();
Expand Down
Loading