HBASE-27547 Close store file readers after region warmup (#4942)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
EungsopYoo 2023-01-28 23:12:18 +09:00 committed by GitHub
parent 235864056c
commit 45fd3f628a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -7756,8 +7756,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
return r.openHRegion(null); return r.openHRegion(null);
} }
public static void warmupHRegion(final RegionInfo info, final TableDescriptor htd, final WAL wal, public static HRegion warmupHRegion(final RegionInfo info, final TableDescriptor htd,
final Configuration conf, final RegionServerServices rsServices, final WAL wal, final Configuration conf, final RegionServerServices rsServices,
final CancelableProgressable reporter) throws IOException { final CancelableProgressable reporter) throws IOException {
Objects.requireNonNull(info, "RegionInfo cannot be null"); Objects.requireNonNull(info, "RegionInfo cannot be null");
@ -7773,6 +7773,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} }
HRegion r = HRegion.newHRegion(tableDir, wal, fs, conf, info, htd, null); HRegion r = HRegion.newHRegion(tableDir, wal, fs, conf, info, htd, null);
r.initializeWarmup(reporter); r.initializeWarmup(reporter);
r.close();
return r;
} }
/** /**

View File

@ -243,6 +243,8 @@ public class HStore
// SFT implementations. // SFT implementations.
private final Supplier<StoreFileWriterCreationTracker> storeFileWriterCreationTrackerFactory; private final Supplier<StoreFileWriterCreationTracker> storeFileWriterCreationTrackerFactory;
private final boolean warmup;
/** /**
* Constructor * Constructor
* @param family HColumnDescriptor for this column * @param family HColumnDescriptor for this column
@ -290,6 +292,7 @@ public class HStore
this.compactionCheckMultiplier = DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER; this.compactionCheckMultiplier = DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER;
} }
this.warmup = warmup;
this.storeEngine = createStoreEngine(this, this.conf, region.getCellComparator()); this.storeEngine = createStoreEngine(this, this.conf, region.getCellComparator());
storeEngine.initialize(warmup); storeEngine.initialize(warmup);
// if require writing to tmp dir first, then we just return null, which indicate that we do not // if require writing to tmp dir first, then we just return null, which indicate that we do not
@ -740,7 +743,7 @@ public class HStore
public Void call() throws IOException { public Void call() throws IOException {
boolean evictOnClose = boolean evictOnClose =
getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() : true; getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() : true;
f.closeStoreFile(evictOnClose); f.closeStoreFile(!warmup && evictOnClose);
return null; return null;
} }
}); });

View File

@ -120,7 +120,7 @@ public class TestWarmupRegion {
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
// Nothing to do. TEST_UTIL.deleteTable(TABLENAME);
} }
protected void runwarmup() throws InterruptedException { protected void runwarmup() throws InterruptedException {
@ -163,4 +163,16 @@ public class TestWarmupRegion {
serverid = (serverid + 1) % 2; serverid = (serverid + 1) % 2;
} }
} }
@Test
public void testWarmupAndClose() throws IOException {
HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
HRegion region = TEST_UTIL.getMiniHBaseCluster().getRegions(TABLENAME).get(0);
RegionInfo info = region.getRegionInfo();
TableDescriptor htd = table.getDescriptor();
HRegion warmedUpRegion =
warmupHRegion(info, htd, rs.getWAL(info), rs.getConfiguration(), rs, null);
assertTrue(warmedUpRegion.isClosed());
}
} }