Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 42AD3200BC2 for ; Thu, 17 Nov 2016 09:17:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 41132160B0B; Thu, 17 Nov 2016 08:17:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8B79A160AFF for ; Thu, 17 Nov 2016 09:17:54 +0100 (CET) Received: (qmail 57404 invoked by uid 500); 17 Nov 2016 08:17:53 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 57395 invoked by uid 99); 17 Nov 2016 08:17:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2016 08:17:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ACD03E0C0A; Thu, 17 Nov 2016 08:17:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: samarth@apache.org To: commits@phoenix.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-3482 Addendum to fix the test failure Date: Thu, 17 Nov 2016 08:17:53 +0000 (UTC) archived-at: Thu, 17 Nov 2016 08:17:55 -0000 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 Authored: Thu Nov 17 00:17:44 2016 -0800 Committer: Samarth 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 { private final AtomicBoolean acquireStatus;