This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 79ecc22a744 HBASE-27547 Close store file readers after region warmup 
(#4942)
79ecc22a744 is described below

commit 79ecc22a744250c713a19b2292015b85c0b846eb
Author: EungsopYoo <[email protected]>
AuthorDate: Sat Jan 28 23:12:18 2023 +0900

    HBASE-27547 Close store file readers after region warmup (#4942)
    
    Signed-off-by: Duo Zhang <[email protected]>
    (cherry picked from commit 45fd3f628ab2ec2268c6449b62a85e7178f511b6)
---
 .../java/org/apache/hadoop/hbase/regionserver/HRegion.java |  6 ++++--
 .../java/org/apache/hadoop/hbase/regionserver/HStore.java  |  5 ++++-
 .../org/apache/hadoop/hbase/master/TestWarmupRegion.java   | 14 +++++++++++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index dba995638bb..ea0b1ef35cf 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -7277,8 +7277,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");
@@ -7294,6 +7294,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;
   }
 
   /**
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
index ec47ebf8da8..63e0ac50b92 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
@@ -243,6 +243,8 @@ public class HStore
   // SFT implementations.
   private final Supplier<StoreFileWriterCreationTracker> 
storeFileWriterCreationTrackerFactory;
 
+  private final boolean warmup;
+
   /**
    * Constructor
    * @param family    HColumnDescriptor for this column
@@ -290,6 +292,7 @@ public class HStore
       this.compactionCheckMultiplier = 
DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER;
     }
 
+    this.warmup = warmup;
     this.storeEngine = createStoreEngine(this, this.conf, 
region.getCellComparator());
     storeEngine.initialize(warmup);
     // 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 {
             boolean evictOnClose =
               getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() 
: true;
-            f.closeStoreFile(evictOnClose);
+            f.closeStoreFile(!warmup && evictOnClose);
             return null;
           }
         });
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestWarmupRegion.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestWarmupRegion.java
index a58f291925c..fdfd919bd39 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestWarmupRegion.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestWarmupRegion.java
@@ -126,7 +126,7 @@ public class TestWarmupRegion {
    */
   @After
   public void tearDown() throws Exception {
-    // Nothing to do.
+    TEST_UTIL.deleteTable(TABLENAME);
   }
 
   protected void runwarmup() throws InterruptedException {
@@ -170,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());
+  }
 }

Reply via email to