Skip to content

Commit 79ecc22

Browse files
EungsopYooApache9
authored andcommitted
HBASE-27547 Close store file readers after region warmup (#4942)
Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 45fd3f6)
1 parent feee45d commit 79ecc22

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7277,8 +7277,8 @@ public static HRegion openReadOnlyFileSystemHRegion(final Configuration conf, fi
72777277
return r.openHRegion(null);
72787278
}
72797279

7280-
public static void warmupHRegion(final RegionInfo info, final TableDescriptor htd, final WAL wal,
7281-
final Configuration conf, final RegionServerServices rsServices,
7280+
public static HRegion warmupHRegion(final RegionInfo info, final TableDescriptor htd,
7281+
final WAL wal, final Configuration conf, final RegionServerServices rsServices,
72827282
final CancelableProgressable reporter) throws IOException {
72837283

72847284
Objects.requireNonNull(info, "RegionInfo cannot be null");
@@ -7294,6 +7294,8 @@ public static void warmupHRegion(final RegionInfo info, final TableDescriptor ht
72947294
}
72957295
HRegion r = HRegion.newHRegion(tableDir, wal, fs, conf, info, htd, null);
72967296
r.initializeWarmup(reporter);
7297+
r.close();
7298+
return r;
72977299
}
72987300

72997301
/**

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ public Set<Path> get() {
243243
// SFT implementations.
244244
private final Supplier<StoreFileWriterCreationTracker> storeFileWriterCreationTrackerFactory;
245245

246+
private final boolean warmup;
247+
246248
/**
247249
* Constructor
248250
* @param family HColumnDescriptor for this column
@@ -290,6 +292,7 @@ protected HStore(final HRegion region, final ColumnFamilyDescriptor family,
290292
this.compactionCheckMultiplier = DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER;
291293
}
292294

295+
this.warmup = warmup;
293296
this.storeEngine = createStoreEngine(this, this.conf, region.getCellComparator());
294297
storeEngine.initialize(warmup);
295298
// if require writing to tmp dir first, then we just return null, which indicate that we do not
@@ -740,7 +743,7 @@ private ImmutableCollection<HStoreFile> closeWithoutLock() throws IOException {
740743
public Void call() throws IOException {
741744
boolean evictOnClose =
742745
getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() : true;
743-
f.closeStoreFile(evictOnClose);
746+
f.closeStoreFile(!warmup && evictOnClose);
744747
return null;
745748
}
746749
});

hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestWarmupRegion.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public boolean evaluate() throws IOException {
126126
*/
127127
@After
128128
public void tearDown() throws Exception {
129-
// Nothing to do.
129+
TEST_UTIL.deleteTable(TABLENAME);
130130
}
131131

132132
protected void runwarmup() throws InterruptedException {
@@ -170,4 +170,16 @@ public void testWarmup() throws Exception {
170170
serverid = (serverid + 1) % 2;
171171
}
172172
}
173+
174+
@Test
175+
public void testWarmupAndClose() throws IOException {
176+
HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
177+
HRegion region = TEST_UTIL.getMiniHBaseCluster().getRegions(TABLENAME).get(0);
178+
RegionInfo info = region.getRegionInfo();
179+
180+
TableDescriptor htd = table.getDescriptor();
181+
HRegion warmedUpRegion =
182+
warmupHRegion(info, htd, rs.getWAL(info), rs.getConfiguration(), rs, null);
183+
assertTrue(warmedUpRegion.isClosed());
184+
}
173185
}

0 commit comments

Comments
 (0)