hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1467515 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
Date Fri, 12 Apr 2013 23:21:14 GMT
Author: tedyu
Date: Fri Apr 12 23:21:13 2013
New Revision: 1467515

URL: http://svn.apache.org/r1467515
Log:
HBASE-8333 TestTableLockManager#testDelete may occasionally fail due to lack of synchronization
between test and handler thread (Ted Yu)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java?rev=1467515&r1=1467514&r2=1467515&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/lock/ZKInterProcessLockBase.java
Fri Apr 12 23:21:13 2013
@@ -313,7 +313,10 @@ public abstract class ZKInterProcessLock
     }
     try {
       if (ZKUtil.checkExists(zkWatcher, lock.getPath()) != -1) {
-        ZKUtil.deleteNode(zkWatcher, lock.getPath(), lock.getVersion());
+        boolean ret = ZKUtil.deleteNode(zkWatcher, lock.getPath(), lock.getVersion());
+        if (!ret && ZKUtil.checkExists(zkWatcher, lock.getPath()) != -1) {
+          throw new IllegalStateException("Couldn't delete " + lock.getPath());
+        }
         if (!acquiredLock.compareAndSet(lock, null)) {
           LOG.debug("Current process no longer holds " + lock + " for " +
               fullyQualifiedZNode);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java?rev=1467515&r1=1467514&r2=1467515&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
Fri Apr 12 23:21:13 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.LargeTests;
 import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver;
 import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
@@ -245,10 +246,19 @@ public class TestTableLockManager {
     admin.deleteTable(TABLE_NAME);
 
     //ensure that znode for the table node has been deleted
-    ZooKeeperWatcher zkWatcher = TEST_UTIL.getZooKeeperWatcher();
-
-    assertTrue(ZKUtil.checkExists(zkWatcher,
-        ZKUtil.joinZNode(zkWatcher.tableLockZNode, Bytes.toString(TABLE_NAME))) < 0);
+    final ZooKeeperWatcher zkWatcher = TEST_UTIL.getZooKeeperWatcher();
+    final String znode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, Bytes.toString(TABLE_NAME));
+    
+    TEST_UTIL.waitFor(5000, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        int ver = ZKUtil.checkExists(zkWatcher, znode);
+        return ver < 0;
+      }
+    });
+    int ver = ZKUtil.checkExists(zkWatcher,
+      ZKUtil.joinZNode(zkWatcher.tableLockZNode, Bytes.toString(TABLE_NAME)));
+    assertTrue("Unexpected znode version " + ver, ver < 0);
 
   }
 



Mime
View raw message