This is an automated email from the ASF dual-hosted git repository.

tkhurana pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.2 by this push:
     new 29c58f034f PHOENIX-7449 Handling already disabled table gracefully 
during dropTables execution (#2022)
29c58f034f is described below

commit 29c58f034f1b41451fff6d66dd6edb8d2395354e
Author: ritegarg <[email protected]>
AuthorDate: Mon Nov 11 09:28:21 2024 -0800

    PHOENIX-7449 Handling already disabled table gracefully during dropTables 
execution (#2022)
    
    PHOENIX-7449 Handling already disabled table gracefully during dropTables 
execution
---
 .../phoenix/query/ConnectionQueryServicesImpl.java    | 19 ++++++++++++++-----
 .../query/ConnectionQueryServicesImplTest.java        |  1 -
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 7ca4c42819..d5dfb32afe 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -138,6 +138,7 @@ import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.NamespaceNotFoundException;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableNotEnabledException;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Append;
 import org.apache.hadoop.hbase.client.CheckAndMutate;
@@ -1718,7 +1719,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                                 
SQLExceptionCode.INCONSISTENT_NAMESPACE_MAPPING_PROPERTIES.getErrorCode()) {
                             try {
                                 // In case we wrongly created SYSTEM.CATALOG 
or SYSTEM:CATALOG, we should drop it
-                                
admin.disableTable(TableName.valueOf(physicalTableName));
+                                disableTable(admin, 
TableName.valueOf(physicalTableName));
                                 
admin.deleteTable(TableName.valueOf(physicalTableName));
                             } catch 
(org.apache.hadoop.hbase.TableNotFoundException ignored) {
                                 // Ignore this since it just means that 
another client with a similar set of
@@ -1874,7 +1875,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
         TableName tn = TableName.valueOf(tableName);
         try (Admin admin = getAdmin()) {
             if (!allowOnlineTableSchemaUpdate()) {
-                admin.disableTable(tn);
+                disableTable(admin, tn);
                 admin.modifyTable(newDesc); // TODO: Update to TableDescriptor
                 admin.enableTable(tn);
             } else {
@@ -2167,6 +2168,14 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
         }
     }
 
+    private void disableTable(Admin admin, TableName tableName) throws 
IOException {
+        try {
+            admin.disableTable(tableName);
+        } catch (TableNotEnabledException e) {
+            LOGGER.info("Table already disabled, continuing with next steps", 
e);
+        }
+    }
+
     private boolean ensureViewIndexTableDropped(byte[] physicalTableName, long 
timestamp) throws SQLException {
         byte[] physicalIndexName = 
MetaDataUtil.getViewIndexPhysicalName(physicalTableName);
         boolean wasDeleted = false;
@@ -2178,7 +2187,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                     final ReadOnlyProps props = this.getProps();
                     final boolean dropMetadata = 
props.getBoolean(DROP_METADATA_ATTRIB, DEFAULT_DROP_METADATA);
                     if (dropMetadata) {
-                        admin.disableTable(physicalIndexTableName);
+                        disableTable(admin, physicalIndexTableName);
                         admin.deleteTable(physicalIndexTableName);
                         clearTableRegionCache(physicalIndexTableName);
                         wasDeleted = true;
@@ -2517,7 +2526,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                     try {
                         TableName tn = TableName.valueOf(tableName);
                         TableDescriptor htableDesc = 
this.getTableDescriptor(tableName);
-                        admin.disableTable(tn);
+                        disableTable(admin, tn);
                         admin.deleteTable(tn);
                         tableStatsCache.invalidateAll(htableDesc);
                         clearTableRegionCache(TableName.valueOf(tableName));
@@ -3946,7 +3955,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                         // co-location of data and index regions. If we just 
modify the
                         // table descriptor when online schema change enabled 
may reopen
                         // the region in same region server instead of 
following data region.
-                        admin.disableTable(table.getTableName());
+                        disableTable(admin,table.getTableName());
                         admin.modifyTable(table);
                         admin.enableTable(table.getTableName());
                     }
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 d0d19c23eb..0737b6b641 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
@@ -61,7 +61,6 @@ import org.apache.phoenix.monitoring.GlobalClientMetrics;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.Before;
 import org.junit.ClassRule;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;

Reply via email to