phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-4523 phoenix.schema.isNamespaceMappingEnabled problem (Karan Mehta)
Date Fri, 12 Jan 2018 00:36:41 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 24288ab31 -> 4609f190f


PHOENIX-4523 phoenix.schema.isNamespaceMappingEnabled problem (Karan Mehta)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 4609f190ff714f1b1b8aa4f29d10cdc2f8520f76
Parents: 24288ab
Author: James Taylor <jtaylor@salesforce.com>
Authored: Thu Jan 11 16:22:09 2018 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Thu Jan 11 16:35:36 2018 -0800

----------------------------------------------------------------------
 .../query/ConnectionQueryServicesImpl.java      | 32 +++++++++++---------
 .../org/apache/phoenix/util/UpgradeUtil.java    |  2 ++
 .../query/ConnectionQueryServicesImplTest.java  |  6 ++--
 3 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4609f190/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 173da65..bba4a87 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -2523,15 +2523,15 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
         }
     }
 
-    void createSysMutexTable(HBaseAdmin admin, ReadOnlyProps props) throws IOException, SQLException
{
+    void createSysMutexTableIfNotExists(HBaseAdmin admin, ReadOnlyProps props) throws IOException,
SQLException {
         try {
-            final TableName mutexTableName = SchemaUtil.getPhysicalTableName(
-                PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME, props);
-            List<TableName> systemTables = getSystemTableNames(admin);
-            if (systemTables.contains(mutexTableName)) {
+            if(admin.tableExists(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME) || admin.tableExists(TableName.valueOf(
+                    PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME,PhoenixDatabaseMetaData.SYSTEM_MUTEX_TABLE_NAME)))
{
                 logger.debug("System mutex table already appears to exist, not creating it");
                 return;
             }
+            final TableName mutexTableName = SchemaUtil.getPhysicalTableName(
+                PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME, props);
             HTableDescriptor tableDesc = new HTableDescriptor(mutexTableName);
             HColumnDescriptor columnDesc = new HColumnDescriptor(
                     PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES);
@@ -2547,10 +2547,17 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
             }
         } catch (TableExistsException e) {
             // Ignore
+        } catch (IOException e) {
+            if(!Iterables.isEmpty(Iterables.filter(Throwables.getCausalChain(e), AccessDeniedException.class))
||
+                    !Iterables.isEmpty(Iterables.filter(Throwables.getCausalChain(e), org.apache.hadoop.hbase.TableNotFoundException.class)))
{
+                // Ignore
+            } else {
+                throw e;
+            }
         }
     }
 
-    List<TableName> getSystemTableNames(HBaseAdmin admin) throws IOException {
+    List<TableName> getSystemTableNamesInDefaultNamespace(HBaseAdmin admin) throws
IOException {
         return Lists.newArrayList(admin.listTableNames(QueryConstants.SYSTEM_SCHEMA_NAME
+ "\\..*"));
     }
 
@@ -2569,7 +2576,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
 
         // Catch the IOException to log the error message and then bubble it up for the client
to retry.
         try {
-            createSysMutexTable(hbaseAdmin, ConnectionQueryServicesImpl.this.getProps());
+            createSysMutexTableIfNotExists(hbaseAdmin, ConnectionQueryServicesImpl.this.getProps());
         } catch (IOException exception) {
             logger.error("Failed to created SYSMUTEX table. Upgrade or migration is not possible
without it. Please retry.");
             throw exception;
@@ -2621,7 +2628,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                             !SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM,
                                     ConnectionQueryServicesImpl.this.getProps())) {
                         try (HBaseAdmin admin = getAdmin()) {
-                            createSysMutexTable(admin, this.getProps());
+                            createSysMutexTableIfNotExists(admin, this.getProps());
                         }
                     }
                     if (acquiredMutexLock = acquireUpgradeMutex(currentServerSideTableTimeStamp,
mutexRowKey)) {
@@ -3164,7 +3171,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                 // below. If the NS does exist and is mapped, the below check will exit gracefully.
             }
 
-            List<TableName> tableNames = getSystemTableNames(admin);
+            List<TableName> tableNames = getSystemTableNamesInDefaultNamespace(admin);
             // No tables exist matching "SYSTEM\..*", they are all already in "SYSTEM:.*"
             if (tableNames.size() == 0) { return; }
             // Try to move any remaining tables matching "SYSTEM\..*" into "SYSTEM:"
@@ -3176,12 +3183,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
             // If we cannot acquire lock, it means some old client is either migrating SYSCAT
or trying to upgrade the
             // schema of SYSCAT table and hence it should not be interrupted
             // Create mutex if not already created
-            if (!tableNames.contains(PhoenixDatabaseMetaData.SYSTEM_MUTEX_HBASE_TABLE_NAME))
{
-                TableName mutexName = SchemaUtil.getPhysicalTableName(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME,
props);
-                if (PhoenixDatabaseMetaData.SYSTEM_MUTEX_HBASE_TABLE_NAME.equals(mutexName)
|| !tableNames.contains(mutexName)) {
-                    createSysMutexTable(admin, props);
-                }
-            }
+            createSysMutexTableIfNotExists(admin, props);
             acquiredMutexLock = acquireUpgradeMutex(MetaDataProtocol.MIN_SYSTEM_TABLE_MIGRATION_TIMESTAMP,
mutexRowKey);
             if(acquiredMutexLock) {
                 logger.debug("Acquired lock in SYSMUTEX table for migrating SYSTEM tables
to SYSTEM namespace");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4609f190/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index 4488e86..c4c2834 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -1779,6 +1779,8 @@ public class UpgradeUtil {
                 admin.deleteTable(srcTableName);
                 logger.info(String.format("deleting snapshot %s..", snapshotName));
                 admin.deleteSnapshot(snapshotName);
+            } else {
+                logger.info(String.format("Destination Table %s already exists. No migration
needed.", destTableName));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4609f190/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
index 4708ffb..b5c3e4a 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java
@@ -49,10 +49,10 @@ public class ConnectionQueryServicesImplTest {
         when(cqs.createSchema(any(List.class), anyString())).thenCallRealMethod();
         doCallRealMethod().when(cqs).ensureSystemTablesMigratedToSystemNamespace(any(ReadOnlyProps.class));
         // Do nothing for this method, just check that it was invoked later
-        doNothing().when(cqs).createSysMutexTable(any(HBaseAdmin.class), any(ReadOnlyProps.class));
+        doNothing().when(cqs).createSysMutexTableIfNotExists(any(HBaseAdmin.class), any(ReadOnlyProps.class));
 
         // Spoof out this call so that ensureSystemTablesUpgrade() will return-fast.
-        when(cqs.getSystemTableNames(any(HBaseAdmin.class))).thenReturn(Collections.<TableName>
emptyList());
+        when(cqs.getSystemTableNamesInDefaultNamespace(any(HBaseAdmin.class))).thenReturn(Collections.<TableName>
emptyList());
 
         // Throw a special exception to check on later
         doThrow(PHOENIX_IO_EXCEPTION).when(cqs).ensureNamespaceCreated(anyString());
@@ -64,7 +64,7 @@ public class ConnectionQueryServicesImplTest {
 
         // Should be called after upgradeSystemTables()
         // Proves that execution proceeded
-        verify(cqs).getSystemTableNames(any(HBaseAdmin.class));
+        verify(cqs).getSystemTableNamesInDefaultNamespace(any(HBaseAdmin.class));
 
         try {
             // Verifies that the exception is propagated back to the caller


Mime
View raw message