You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/11/12 15:09:08 UTC

[hbase] branch branch-2.4 updated: HBASE-26438 Fix flaky test TestHStore.testCompactingMemStoreCellExceedInmemoryFlushSize (#3834)

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

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


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 5dd23e5  HBASE-26438 Fix flaky test TestHStore.testCompactingMemStoreCellExceedInmemoryFlushSize (#3834)
5dd23e5 is described below

commit 5dd23e5b8c7bc965e8a079dd025bd4c904998b2d
Author: chenglei <ch...@apache.org>
AuthorDate: Fri Nov 12 22:51:40 2021 +0800

    HBASE-26438 Fix flaky test TestHStore.testCompactingMemStoreCellExceedInmemoryFlushSize (#3834)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../hadoop/hbase/regionserver/TestHStore.java      | 35 ++++++++++++++++++++--
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
index 577cbcc..35d244f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
@@ -240,6 +240,7 @@ public class TestHStore {
     } else {
       store = new MyStore(region, hcd, conf, hook, switchToPread);
     }
+    region.stores.put(store.getColumnFamilyDescriptor().getName(), store);
     return store;
   }
 
@@ -1808,14 +1809,16 @@ public class TestHStore {
   // InmemoryFlushSize
   @Test(timeout = 60000)
   public void testCompactingMemStoreCellExceedInmemoryFlushSize()
-      throws IOException, InterruptedException {
+      throws Exception {
     Configuration conf = HBaseConfiguration.create();
-    conf.set(HStore.MEMSTORE_CLASS_NAME, CompactingMemStore.class.getName());
+    conf.set(HStore.MEMSTORE_CLASS_NAME, MyCompactingMemStore6.class.getName());
 
     init(name.getMethodName(), conf, ColumnFamilyDescriptorBuilder.newBuilder(family)
         .setInMemoryCompaction(MemoryCompactionPolicy.BASIC).build());
 
-    int size = (int) ((CompactingMemStore) store.memstore).getInmemoryFlushSize();
+    MyCompactingMemStore6 myCompactingMemStore = ((MyCompactingMemStore6) store.memstore);
+
+    int size = (int) (myCompactingMemStore.getInmemoryFlushSize());
     byte[] value = new byte[size + 1];
 
     MemStoreSizing memStoreSizing = new NonThreadSafeMemStoreSizing();
@@ -1826,6 +1829,8 @@ public class TestHStore {
     store.add(cell, memStoreSizing);
     assertTrue(memStoreSizing.getCellsCount() == 1);
     assertTrue(memStoreSizing.getDataSize() == cellByteSize);
+    // Waiting the in memory compaction completed, see HBASE-26438
+    myCompactingMemStore.inMemoryCompactionEndCyclicBarrier.await();
   }
 
   // This test is for HBASE-26210 also, test write large cell and small cell concurrently when
@@ -2812,4 +2817,28 @@ public class TestHStore {
       }
     }
   }
+
+  public static class MyCompactingMemStore6 extends CompactingMemStore {
+    private final CyclicBarrier inMemoryCompactionEndCyclicBarrier = new CyclicBarrier(2);
+
+    public MyCompactingMemStore6(Configuration conf, CellComparatorImpl cellComparator,
+        HStore store, RegionServicesForStores regionServices,
+        MemoryCompactionPolicy compactionPolicy) throws IOException {
+      super(conf, cellComparator, store, regionServices, compactionPolicy);
+    }
+
+    @Override
+    void inMemoryCompaction() {
+      try {
+        super.inMemoryCompaction();
+      } finally {
+        try {
+          inMemoryCompactionEndCyclicBarrier.await();
+        } catch (Throwable e) {
+          throw new RuntimeException(e);
+        }
+
+      }
+    }
+  }
 }