phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject phoenix git commit: PHOENIX-3482 Addendum to fix the test failure
Date Thu, 17 Nov 2016 08:17:53 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.8-HBase-0.98 988f349b2 -> ebe8724ad


PHOENIX-3482 Addendum to fix the test failure


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

Branch: refs/heads/4.8-HBase-0.98
Commit: ebe8724ada4a9421d75556bc24e2d34da701364e
Parents: 988f349
Author: Samarth <samarth.jain@salesforce.com>
Authored: Thu Nov 17 00:17:44 2016 -0800
Committer: Samarth <samarth.jain@salesforce.com>
Committed: Thu Nov 17 00:17:44 2016 -0800

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/UpgradeIT.java   | 31 ++++++++++++++------
 1 file changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ebe8724a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
index 2059c78..5280f4e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
@@ -573,10 +573,12 @@ public class UpgradeIT extends BaseHBaseManagedTimeIT {
         ConnectionQueryServices services = null;
         byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA,
                 generateRandomString());
+        boolean dropSysMutexTable = false;
         try (Connection conn = getConnection(false, null)) {
             services = conn.unwrap(PhoenixConnection.class).getQueryServices();
             assertTrue(((ConnectionQueryServicesImpl)services)
                     .acquireUpgradeMutex(MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0,
mutexRowKey));
+            dropSysMutexTable = true;
             try {
                 ((ConnectionQueryServicesImpl)services)
                         .acquireUpgradeMutex(MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0,
mutexRowKey);
@@ -586,6 +588,16 @@ public class UpgradeIT extends BaseHBaseManagedTimeIT {
             }
             assertTrue(((ConnectionQueryServicesImpl)services).releaseUpgradeMutex(mutexRowKey));
             assertFalse(((ConnectionQueryServicesImpl)services).releaseUpgradeMutex(mutexRowKey));
+        } finally {
+            // We need to drop the SYSTEM.MUTEX table else other tests calling acquireUpgradeMutex
will unexpectedly fail because they
+            // won't see the UNLOCKED cell present for their key. This cell is inserted into
the table the first time we create the 
+            // SYSTEM.MUTEX table.
+            if (services != null && dropSysMutexTable) {
+                try (HBaseAdmin admin = services.getAdmin()) {
+                    admin.disableTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES);
+                    admin.deleteTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES);
+                }
+            }
         }
     }
     
@@ -596,6 +608,7 @@ public class UpgradeIT extends BaseHBaseManagedTimeIT {
         final CountDownLatch latch = new CountDownLatch(2);
         final AtomicInteger numExceptions = new AtomicInteger(0);
         ConnectionQueryServices services = null;
+        boolean dropSysMutexTable = false;
         try (Connection conn = getConnection(false, null)) {
             services = conn.unwrap(PhoenixConnection.class).getQueryServices();
             final byte[] mutexKey = Bytes.toBytes(generateRandomString());
@@ -612,23 +625,23 @@ public class UpgradeIT extends BaseHBaseManagedTimeIT {
             task1.get();
             task2.get();
             assertTrue("One of the threads should have acquired the mutex", mutexStatus1.get()
|| mutexStatus2.get());
+            dropSysMutexTable = true;
             assertNotEquals("One and only one thread should have acquired the mutex ", mutexStatus1.get(),
                     mutexStatus2.get());
             assertEquals("One and only one thread should have caught UpgradeRequiredException
", 1, numExceptions.get());
         } finally {
-            if (services != null) {
-                releaseUpgradeMutex(services);
+            // We need to drop the SYSTEM.MUTEX table else other tests calling acquireUpgradeMutex
will unexpectedly fail because they
+            // won't see the UNLOCKED cell present for their key. This cell is inserted into
the table the first time we create the 
+            // SYSTEM.MUTEX table.
+            if (services != null && dropSysMutexTable) {
+                try (HBaseAdmin admin = services.getAdmin()) {
+                    admin.disableTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES);
+                    admin.deleteTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES);
+                }
             }
         }
     }
     
-    private void releaseUpgradeMutex(ConnectionQueryServices services) {
-        byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA,
-                PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE);
-        ((ConnectionQueryServicesImpl)services).releaseUpgradeMutex(mutexRowKey);
-        
-    }
-    
     private static class AcquireMutexRunnable implements Callable<Void> {
         
         private final AtomicBoolean acquireStatus;


Mime
View raw message