HBASE-27547 Close store file readers after region warmup (#4942)
Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 45fd3f628ab2ec2268c6449b62a85e7178f511b6)
This commit is contained in:
parent
2e727a859b
commit
93ad9c4114
@ -7944,8 +7944,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||
return r.openHRegion(null);
|
||||
}
|
||||
|
||||
public static void warmupHRegion(final RegionInfo info, final TableDescriptor htd, final WAL wal,
|
||||
final Configuration conf, final RegionServerServices rsServices,
|
||||
public static HRegion warmupHRegion(final RegionInfo info, final TableDescriptor htd,
|
||||
final WAL wal, final Configuration conf, final RegionServerServices rsServices,
|
||||
final CancelableProgressable reporter) throws IOException {
|
||||
|
||||
Objects.requireNonNull(info, "RegionInfo cannot be null");
|
||||
@ -7961,6 +7961,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||
}
|
||||
HRegion r = HRegion.newHRegion(tableDir, wal, fs, conf, info, htd, null);
|
||||
r.initializeWarmup(reporter);
|
||||
r.close();
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +226,8 @@ public class HStore
|
||||
|
||||
private final StoreContext storeContext;
|
||||
|
||||
private final boolean warmup;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param family HColumnDescriptor for this column
|
||||
@ -279,6 +281,7 @@ public class HStore
|
||||
conf.getInt("hbase.hstore.close.check.interval", 10 * 1000 * 1000 /* 10 MB */);
|
||||
}
|
||||
|
||||
this.warmup = warmup;
|
||||
this.storeEngine = createStoreEngine(this, this.conf, region.getCellComparator());
|
||||
List<HStoreFile> hStoreFiles = loadStoreFiles(warmup);
|
||||
// Move the storeSize calculation out of loadStoreFiles() method, because the secondary read
|
||||
@ -918,7 +921,7 @@ public class HStore
|
||||
public Void call() throws IOException {
|
||||
boolean evictOnClose =
|
||||
getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() : true;
|
||||
f.closeStoreFile(evictOnClose);
|
||||
f.closeStoreFile(!warmup && evictOnClose);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.CompactionState;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||
import org.apache.hadoop.hbase.client.Table;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
@ -125,7 +126,7 @@ public class TestWarmupRegion {
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
// Nothing to do.
|
||||
TEST_UTIL.deleteTable(TABLENAME);
|
||||
}
|
||||
|
||||
protected void runwarmup() throws InterruptedException {
|
||||
@ -169,4 +170,16 @@ public class TestWarmupRegion {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user