Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotEnabledException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Append;
Expand Down Expand Up @@ -2007,6 +2008,19 @@ private TableDescriptor ensureTableCreated(byte[] physicalTableName,
}
}

// The physical HBase table may have been left disabled by a previous failed drop
// (or manual admin action) while its Phoenix metadata was removed. Re-enable it so
// downstream steps (modifyTable, post-DDL SYSTEM.CATALOG RPC, and the client's
// subsequent scans) see a usable table.
if (
tableType != PTableType.SYSTEM
&& admin.isTableDisabled(TableName.valueOf(physicalTableName))
) {
LOGGER.info("Re-enabling disabled HBase table {} during CREATE TABLE",
Bytes.toString(physicalTableName));
enableTable(admin, TableName.valueOf(physicalTableName));
}

if (!modifyExistingMetaData) {
return existingDesc; // Caller already knows that no metadata was changed
}
Expand Down Expand Up @@ -2450,6 +2464,14 @@ private void disableTable(Admin admin, TableName tableName) throws IOException {
}
}

private void enableTable(Admin admin, TableName tableName) throws IOException {
try {
admin.enableTable(tableName);
} catch (TableNotDisabledException e) {
LOGGER.info("Table already enabled, continuing with next steps", e);
}
}

private boolean ensureViewIndexTableDropped(byte[] physicalTableName, long timestamp)
throws SQLException {
byte[] physicalIndexName = MetaDataUtil.getViewIndexPhysicalName(physicalTableName);
Expand Down