Repository: hbase
Updated Branches:
  refs/heads/branch-1 d4b5645a4 -> df5785925


HBASE-16725 Don't let flushThread hang in TestHRegion


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/df578592
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/df578592
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/df578592

Branch: refs/heads/branch-1
Commit: df578592582059e08fcbbb8a0bc6b950a9768323
Parents: d4b5645
Author: tedyu <[email protected]>
Authored: Thu Sep 29 06:57:02 2016 -0700
Committer: tedyu <[email protected]>
Committed: Thu Sep 29 06:57:02 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/TestHRegion.java  | 40 ++++++++++++--------
 1 file changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/df578592/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
index de844ba..1265468 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
@@ -3751,8 +3751,8 @@ public class TestHRegion {
 
     String method = "testFlushCacheWhileScanning";
     this.region = initHRegion(tableName, method, CONF, family);
+    FlushThread flushThread = new FlushThread();
     try {
-      FlushThread flushThread = new FlushThread();
       flushThread.start();
 
       Scan scan = new Scan();
@@ -3771,7 +3771,7 @@ public class TestHRegion {
         region.put(put);
 
         if (i != 0 && i % compactInterval == 0) {
-          // System.out.println("iteration = " + i);
+          LOG.debug("iteration = " + i+ " ts="+System.currentTimeMillis());
           region.compact(true);
         }
 
@@ -3790,15 +3790,20 @@ public class TestHRegion {
           if (!toggle) {
             flushThread.flush();
           }
-          assertEquals("i=" + i, expectedCount, res.size());
+          assertEquals("toggle="+toggle+"i=" + i + " 
ts="+System.currentTimeMillis(),
+              expectedCount, res.size());
           toggle = !toggle;
         }
       }
 
-      flushThread.done();
-      flushThread.join();
-      flushThread.checkNoError();
     } finally {
+      try {
+        flushThread.done();
+        flushThread.join();
+        flushThread.checkNoError();
+      } catch (InterruptedException ie) {
+        LOG.warn("Caught exception when joining with flushThread", ie);
+      }
       HRegion.closeHRegion(this.region);
       this.region = null;
     }
@@ -3888,12 +3893,12 @@ public class TestHRegion {
 
     String method = "testWritesWhileScanning";
     this.region = initHRegion(tableName, method, CONF, families);
+    FlushThread flushThread = new FlushThread();
+    PutThread putThread = new PutThread(numRows, families, qualifiers);
     try {
-      PutThread putThread = new PutThread(numRows, families, qualifiers);
       putThread.start();
       putThread.waitForFirstPut();
 
-      FlushThread flushThread = new FlushThread();
       flushThread.start();
 
       Scan scan = new Scan(Bytes.toBytes("row0"), Bytes.toBytes("row1"));
@@ -3928,19 +3933,22 @@ public class TestHRegion {
           prevTimestamp = timestamp;
         }
       }
-
       putThread.done();
-
       region.flush(true);
 
-      putThread.join();
-      putThread.checkNoError();
-
-      flushThread.done();
-      flushThread.join();
-      flushThread.checkNoError();
     } finally {
       try {
+        flushThread.done();
+        flushThread.join();
+        flushThread.checkNoError();
+
+        putThread.join();
+        putThread.checkNoError();
+      } catch (InterruptedException ie) {
+        LOG.warn("Caught exception when joining with flushThread", ie);
+      }
+
+      try {
         LOG.info("Before close: " + this.region.getMVCC());
         HRegion.closeHRegion(this.region);
       } catch (DroppedSnapshotException dse) {

Reply via email to