This is an automated email from the ASF dual-hosted git repository. skadam pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new fab96c3 PHOENIX-5385: GlobalIndexChecker coproc doesn't load on view indexes fab96c3 is described below commit fab96c3a9d031045e876cbea11033507e5c425ca Author: s.kadam <ska...@apache.org> AuthorDate: Tue Jul 16 12:14:41 2019 -0700 PHOENIX-5385: GlobalIndexChecker coproc doesn't load on view indexes --- .../end2end/ParameterizedIndexUpgradeToolIT.java | 31 +++++------ .../apache/phoenix/end2end/index/DropColumnIT.java | 9 ++-- .../org/apache/phoenix/execute/MutationState.java | 60 ++++++++++++++-------- .../phoenix/mapreduce/index/IndexUpgradeTool.java | 23 +++++---- .../phoenix/query/ConnectionQueryServicesImpl.java | 13 +++-- 5 files changed, 81 insertions(+), 55 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java index d2d68e2..2cde910 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java @@ -25,6 +25,7 @@ import org.apache.phoenix.hbase.index.IndexRegionObserver; import org.apache.phoenix.hbase.index.Indexer; import org.apache.phoenix.index.GlobalIndexChecker; import org.apache.phoenix.jdbc.PhoenixConnection; + import org.apache.phoenix.mapreduce.index.IndexTool; import org.apache.phoenix.mapreduce.index.IndexUpgradeTool; import org.apache.phoenix.query.BaseTest; @@ -60,11 +61,11 @@ import static org.apache.phoenix.mapreduce.index.IndexUpgradeTool.UPGRADE_OP; @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class ParameterizedIndexUpgradeToolIT extends BaseTest { - //Please do not remove/uncomment commented items in the list until PHOENIX-5385 is fixed private static final String [] INDEXES_LIST = {"TEST.INDEX1", "TEST.INDEX2", "TEST1.INDEX3", - "TEST1.INDEX2","TEST1.INDEX1","TEST.INDEX3"/*, "_IDX_TEST.MOCK1", "_IDX_TEST1.MOCK2"*/}; - private static final String [] INDEXES_LIST_NAMESPACE = {"TEST:INDEX1", "TEST:INDEX2", "TEST1:INDEX3", - "TEST1:INDEX2","TEST1:INDEX1","TEST:INDEX3"/*, "TEST:_IDX_MOCK1", "TEST1:_IDX_MOCK2"*/}; + "TEST1.INDEX2","TEST1.INDEX1","TEST.INDEX3", "_IDX_TEST.MOCK1", "_IDX_TEST1.MOCK2"}; + private static final String [] INDEXES_LIST_NAMESPACE = {"TEST:INDEX1", "TEST:INDEX2" + , "TEST1:INDEX3", "TEST1:INDEX2","TEST1:INDEX1" + , "TEST:INDEX3", "TEST:_IDX_MOCK1", "TEST1:_IDX_MOCK2"}; private static final String [] TABLE_LIST = {"TEST.MOCK1","TEST1.MOCK2","TEST.MOCK3"}; private static final String [] TABLE_LIST_NAMESPACE = {"TEST:MOCK1","TEST1:MOCK2","TEST:MOCK3"}; @@ -99,8 +100,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { .getQueryServices(); admin = queryServices.getAdmin(); iut = new IndexUpgradeTool(upgrade ? UPGRADE_OP : ROLLBACK_OP, INPUT_LIST, - null, "/tmp/index_upgrade_" + UUID.randomUUID().toString(),true, - Mockito.mock(IndexTool.class)); + null, "/tmp/index_upgrade_" + UUID.randomUUID().toString(),true, Mockito.mock( + IndexTool.class)); iut.setConf(getUtility().getConfiguration()); iut.setTest(true); if (!mutable) { @@ -141,8 +142,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { + "PRIMARY KEY, name varchar, city varchar, phone bigint)"+tableDDLOptions); conn.createStatement().execute("CREATE TABLE TEST.MOCK3 (id bigint NOT NULL " + "PRIMARY KEY, name varchar, age bigint)"+tableDDLOptions); - /* - Please do not remove/uncomment commented code until PHOENIX-5385 is fixed + //views conn.createStatement().execute("CREATE VIEW TEST.MOCK1_VIEW (view_column varchar) " + "AS SELECT * FROM TEST.MOCK1 WHERE a.name = 'a'"); @@ -158,7 +158,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { conn.createStatement().execute("CREATE INDEX MOCK2_INDEX1 ON TEST1.MOCK2_VIEW " + "(state, city)"); conn.createStatement().execute("CREATE INDEX MOCK1_INDEX3 ON TEST.MOCK1_VIEW " - + "(view_column)");*/ + + "(view_column)"); //indexes conn.createStatement().execute("CREATE INDEX INDEX1 ON TEST.MOCK1 (sal, a.name)"); conn.createStatement().execute("CREATE INDEX INDEX2 ON TEST.MOCK1 (a.name)"); @@ -190,7 +190,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { } } - private void checkNewIndexingCoprocessors(String [] indexList, String [] tableList) throws IOException { + private void checkNewIndexingCoprocessors(String [] indexList, String [] tableList) + throws IOException { if (mutable) { for (String table : tableList) { Assert.assertTrue(admin.getDescriptor(TableName.valueOf(table)) @@ -205,7 +206,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { } } - private void checkOldIndexingCoprocessors(String [] indexList, String [] tableList) throws IOException { + private void checkOldIndexingCoprocessors(String [] indexList, String [] tableList) + throws IOException { if (mutable) { for (String table : tableList) { Assert.assertTrue(admin.getDescriptor(TableName.valueOf(table)) @@ -234,7 +236,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { }); } - public ParameterizedIndexUpgradeToolIT(boolean mutable, boolean upgrade, boolean isNamespaceEnabled) { + public ParameterizedIndexUpgradeToolIT(boolean mutable, boolean upgrade, + boolean isNamespaceEnabled) { this.mutable = mutable; this.upgrade = upgrade; this.isNamespaceEnabled = isNamespaceEnabled; @@ -304,8 +307,6 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { conn.createStatement().execute("DROP INDEX INDEX3 ON TEST1.MOCK2"); conn.createStatement().execute("DROP INDEX INDEX3 ON TEST.MOCK3"); - /* - Please do not remove/uncomment commented code until PHOENIX-5385 is fixed conn.createStatement().execute("DROP INDEX MOCK1_INDEX3 ON TEST.MOCK1_VIEW"); conn.createStatement().execute("DROP INDEX MOCK1_INDEX1 ON TEST.MOCK1_VIEW1"); conn.createStatement().execute("DROP INDEX MOCK1_INDEX2 ON TEST.MOCK1_VIEW1"); @@ -313,7 +314,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest { conn.createStatement().execute("DROP VIEW TEST.MOCK1_VIEW"); conn.createStatement().execute("DROP VIEW TEST.MOCK1_VIEW1"); - conn.createStatement().execute("DROP VIEW TEST1.MOCK2_VIEW"); */ + conn.createStatement().execute("DROP VIEW TEST1.MOCK2_VIEW"); conn.createStatement().execute("DROP TABLE TEST.MOCK1"); conn.createStatement().execute("DROP TABLE TEST1.MOCK2"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java index 16e38dd..6bc5031 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java @@ -34,6 +34,7 @@ import java.util.Collection; import java.util.Properties; import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; @@ -318,6 +319,7 @@ public class DropColumnIT extends ParallelStatsDisabledIT { String localIndexTableName1 = "LOCAL_" + indexTableName + "_1"; String localIndexTableName2 = "LOCAL_" + indexTableName + "_2"; try (Connection conn = getConnection()) { + conn.setAutoCommit(false); conn.createStatement().execute( "CREATE TABLE " + dataTableFullName @@ -342,8 +344,6 @@ public class DropColumnIT extends ParallelStatsDisabledIT { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); PTable dataTable = pconn.getTable(new PTableKey(null, dataTableFullName)); assertEquals("Unexpected number of indexes ", 3, dataTable.getIndexes().size()); - PTable indexTable = dataTable.getIndexes().get(0); - byte[] indexTablePhysicalName = indexTable.getPhysicalName().getBytes(); PName localIndexTablePhysicalName = dataTable.getIndexes().get(1).getPhysicalName(); // drop v2 which causes the regular index and first local index to be dropped @@ -373,9 +373,10 @@ public class DropColumnIT extends ParallelStatsDisabledIT { // verify that the regular index physical table was dropped try { - conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(indexTablePhysicalName); + conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin().getDescriptor( + TableName.valueOf(indexTableName)); fail("Index table should have been dropped"); - } catch (TableNotFoundException e) { + } catch (org.apache.hadoop.hbase.TableNotFoundException e) { } // verify that the local index physical table was *not* dropped diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java index cc57769..44760a8 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java @@ -43,12 +43,11 @@ import javax.annotation.concurrent.Immutable; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; @@ -85,6 +84,7 @@ import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PIndexState; import org.apache.phoenix.schema.PMetaData; import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PNameFactory; import org.apache.phoenix.schema.PRow; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableRef; @@ -104,6 +104,7 @@ import org.apache.phoenix.util.EncodedColumnsUtil; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.IndexUtil; import org.apache.phoenix.util.LogUtil; +import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixKeyValueUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.SQLCloseable; @@ -509,7 +510,7 @@ public class MutationState implements SQLCloseable { return ptr; } - private Iterator<Pair<PName, List<Mutation>>> addRowMutations(final TableRef tableRef, + private Iterator<Pair<PTable, List<Mutation>>> addRowMutations(final TableRef tableRef, final MultiRowMutationState values, final long mutationTimestamp, final long serverTimestamp, boolean includeAllIndexes, final boolean sendAll) { final PTable table = tableRef.getTable(); @@ -522,7 +523,7 @@ public class MutationState implements SQLCloseable { .newArrayListWithExpectedSize(values.size()) : null; generateMutations(tableRef, mutationTimestamp, serverTimestamp, values, mutationList, mutationsPertainingToIndex); - return new Iterator<Pair<PName, List<Mutation>>>() { + return new Iterator<Pair<PTable, List<Mutation>>>() { boolean isFirst = true; Map<byte[], List<Mutation>> indexMutationsMap = null; @@ -532,10 +533,10 @@ public class MutationState implements SQLCloseable { } @Override - public Pair<PName, List<Mutation>> next() { + public Pair<PTable, List<Mutation>> next() { if (isFirst) { isFirst = false; - return new Pair<>(table.getPhysicalName(), mutationList); + return new Pair<>(table, mutationList); } PTable index = indexes.next(); @@ -587,8 +588,9 @@ public class MutationState implements SQLCloseable { } catch (SQLException | IOException e) { throw new IllegalDataException(e); } - return new Pair<PName, List<Mutation>>(index.getPhysicalName(), - indexMutations == null ? Collections.<Mutation> emptyList() : indexMutations); + return new Pair<PTable, List<Mutation>>(index, + indexMutations == null ? Collections.<Mutation> emptyList() + : indexMutations); } @Override @@ -692,8 +694,9 @@ public class MutationState implements SQLCloseable { private Iterator<Pair<byte[], List<Mutation>>> innerIterator = init(); private Iterator<Pair<byte[], List<Mutation>>> init() { - final Iterator<Pair<PName, List<Mutation>>> mutationIterator = addRowMutations(current.getKey(), - current.getValue(), mutationTimestamp, serverTimestamp, includeMutableIndexes, true); + final Iterator<Pair<PTable, List<Mutation>>> mutationIterator = + addRowMutations(current.getKey(), current.getValue(), + mutationTimestamp, serverTimestamp, includeMutableIndexes, true); return new Iterator<Pair<byte[], List<Mutation>>>() { @Override public boolean hasNext() { @@ -702,8 +705,9 @@ public class MutationState implements SQLCloseable { @Override public Pair<byte[], List<Mutation>> next() { - Pair<PName, List<Mutation>> pair = mutationIterator.next(); - return new Pair<byte[], List<Mutation>>(pair.getFirst().getBytes(), pair.getSecond()); + Pair<PTable, List<Mutation>> pair = mutationIterator.next(); + return new Pair<byte[], List<Mutation>>(pair.getFirst().getPhysicalName() + .getBytes(), pair.getSecond()); } @Override @@ -839,14 +843,16 @@ public class MutationState implements SQLCloseable { private final PName hTableName; @Nonnull private final TableRef origTableRef; + private final PTable pTable; - public TableInfo(boolean isDataTable, PName hTableName, TableRef origTableRef) { + public TableInfo(boolean isDataTable, PName hTableName, TableRef origTableRef, PTable pTable) { super(); checkNotNull(hTableName); checkNotNull(origTableRef); this.isDataTable = isDataTable; this.hTableName = hTableName; this.origTableRef = origTableRef; + this.pTable = pTable; } public boolean isDataTable() { @@ -861,6 +867,10 @@ public class MutationState implements SQLCloseable { return origTableRef; } + public PTable getPTable() { + return pTable; + } + @Override public int hashCode() { final int prime = 31; @@ -878,6 +888,8 @@ public class MutationState implements SQLCloseable { TableInfo other = (TableInfo)obj; if (!hTableName.equals(other.hTableName)) return false; if (isDataTable != other.isDataTable) return false; + if (!pTable.equals(other.pTable)) return false; + return true; } @@ -916,17 +928,20 @@ public class MutationState implements SQLCloseable { long mutationTimestamp = scn == null ? (table.isTransactional() == true ? HConstants.LATEST_TIMESTAMP : EnvironmentEdgeManager.currentTimeMillis()) : scn; - Iterator<Pair<PName, List<Mutation>>> + Iterator<Pair<PTable, List<Mutation>>> mutationsIterator = addRowMutations(tableRef, multiRowMutationState, mutationTimestamp, serverTimestamp, false, sendAll); // build map from physical table to mutation list boolean isDataTable = true; while (mutationsIterator.hasNext()) { - Pair<PName, List<Mutation>> pair = mutationsIterator.next(); - PName hTableName = pair.getFirst(); + Pair<PTable, List<Mutation>> pair = mutationsIterator.next(); + PTable logicalTable = pair.getFirst(); List<Mutation> mutationList = pair.getSecond(); - TableInfo tableInfo = new TableInfo(isDataTable, hTableName, tableRef); + + TableInfo tableInfo = new TableInfo(isDataTable, logicalTable.getPhysicalName(), + tableRef, logicalTable); + List<Mutation> oldMutationList = physicalTableMutationMap.put(tableInfo, mutationList); @@ -972,7 +987,6 @@ public class MutationState implements SQLCloseable { + verifiedOrDeletedIndexMutations.toString(), ex); } - } } @@ -1198,11 +1212,13 @@ public class MutationState implements SQLCloseable { while (mapIter.hasNext()) { Entry<TableInfo, List<Mutation>> pair = mapIter.next(); TableInfo tableInfo = pair.getKey(); - if (tableInfo.getOrigTableRef().getTable().isImmutableRows() && IndexUtil.isGlobalIndexCheckerEnabled(connection, tableInfo.getHTableName())) { - PTable table = PhoenixRuntime.getTable(connection, tableInfo.getHTableName().getString()); - byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(table); - byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(table).getFirst(); + PTable logicalTable = tableInfo.getPTable(); + if (tableInfo.getOrigTableRef().getTable().isImmutableRows() + && IndexUtil.isGlobalIndexCheckerEnabled(connection, + tableInfo.getHTableName())) { + byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(logicalTable); + byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(logicalTable).getFirst(); List<Mutation> mutations = pair.getValue(); for (Mutation m : mutations) { diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java index 86ed66b..4d68165 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java @@ -48,6 +48,7 @@ import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; import java.sql.ResultSet; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -96,6 +97,7 @@ public class IndexUpgradeTool extends Configured { public static final String UPGRADE_OP = "upgrade"; public static final String ROLLBACK_OP = "rollback"; private static final String GLOBAL_INDEX_ID = "#NA#"; + private IndexTool indexingTool; private HashMap<String, HashSet<String>> tablesAndIndexes = new HashMap<>(); private HashMap<String, HashMap<String,String>> rebuildMap = new HashMap<>(); @@ -106,7 +108,6 @@ public class IndexUpgradeTool extends Configured { private String inputTables; private String logFile; private String inputFile; - private IndexTool indexingTool; private boolean test = false; @@ -160,13 +161,13 @@ public class IndexUpgradeTool extends Configured { } public IndexUpgradeTool(String mode, String tables, String inputFile, - String outputFile, boolean dryRun, IndexTool indexingTool) { + String outputFile, boolean dryRun, IndexTool indexTool) { this.operation = mode; this.inputTables = tables; this.inputFile = inputFile; this.logFile = outputFile; this.dryRun = dryRun; - this.indexingTool = indexingTool; + this.indexingTool = indexTool; } public IndexUpgradeTool () { } @@ -253,7 +254,6 @@ public class IndexUpgradeTool extends Configured { inputFile = cmdLine.getOptionValue(TABLE_CSV_FILE_OPTION.getOpt()); dryRun = cmdLine.hasOption(DRY_RUN_OPTION.getOpt()); syncRebuild = cmdLine.hasOption(INDEX_SYNC_REBUILD_OPTION.getOpt()); - indexingTool = new IndexTool(); } @VisibleForTesting @@ -340,7 +340,11 @@ public class IndexUpgradeTool extends Configured { modifyTable(admin, dataTableFullName, indexes); enableTable(admin, dataTableFullName, indexes); if (upgrade) { - rebuildIndexes(dataTableFullName, conf); + if(!test) { + indexingTool = new IndexTool(); + } + indexingTool.setConf(conf); + rebuildIndexes(dataTableFullName, indexingTool); } } catch (IOException | SQLException | InterruptedException e) { LOGGER.severe("Something went wrong while executing " + operation + " steps " + e); @@ -461,7 +465,7 @@ public class IndexUpgradeTool extends Configured { } } - private int rebuildIndexes(String dataTable, Configuration conf) { + private int rebuildIndexes(String dataTable, IndexTool indexingTool) { String schema = SchemaUtil.getSchemaNameFromFullName(dataTable); String table = SchemaUtil.getTableNameFromFullName(dataTable); for(Map.Entry<String, String> indexMap : rebuildMap.get(dataTable).entrySet()) { @@ -469,12 +473,11 @@ public class IndexUpgradeTool extends Configured { String tenantId = indexMap.getValue(); String indexName = SchemaUtil.getTableNameFromFullName(index); String outFile = "/tmp/index_rebuild_" + indexName + - (tenantId.equals(GLOBAL_INDEX_ID)?"":"_"+tenantId) +"_"+ UUID.randomUUID().toString(); + (GLOBAL_INDEX_ID.equals(tenantId)?"":"_"+tenantId) +"_"+ UUID.randomUUID().toString(); String[] args = { "-s", schema, "-dt", table, "-it", indexName, "-direct", "-op", outFile }; - indexingTool.setConf(conf); - List<String> list = Arrays.asList(args); - if (!tenantId.equals(GLOBAL_INDEX_ID)) { + ArrayList<String> list = new ArrayList<>(Arrays.asList(args)); + if (!GLOBAL_INDEX_ID.equals(tenantId)) { list.add("-tenant"); list.add(tenantId); } 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 77b541a..16c8777 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 @@ -916,12 +916,17 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement boolean indexRegionObserverEnabled = config.getBoolean( QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_REGION_OBSERVER_ENABLED); + boolean isViewIndex = TRUE_BYTES_AS_STRING + .equals(tableProps.get(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_NAME)); - if (tableType == PTableType.INDEX && !isTransactional) { + if ((tableType == PTableType.INDEX && !isTransactional) || isViewIndex) { if (!indexRegionObserverEnabled && newDesc.hasCoprocessor(GlobalIndexChecker.class.getName())) { builder.removeCoprocessor(GlobalIndexChecker.class.getName()); } else if (indexRegionObserverEnabled && !newDesc.hasCoprocessor(GlobalIndexChecker.class.getName()) && !isLocalIndexTable(newDesc.getColumnFamilyNames())) { + if (newDesc.hasCoprocessor(IndexRegionObserver.class.getName())) { + builder.removeCoprocessor(IndexRegionObserver.class.getName()); + } builder.addCoprocessor(GlobalIndexChecker.class.getName(), null, priority - 1, null); } } @@ -943,7 +948,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement // Since indexes can't have indexes, don't install our indexing coprocessor for indexes. // Also don't install on the SYSTEM.CATALOG and SYSTEM.STATS table because we use // all-or-none mutate class which break when this coprocessor is installed (PHOENIX-1318). - if ((tableType != PTableType.INDEX && tableType != PTableType.VIEW) + if ((tableType != PTableType.INDEX && tableType != PTableType.VIEW && !isViewIndex) && !SchemaUtil.isMetaTable(tableName) && !SchemaUtil.isStatsTable(tableName)) { if (isTransactional) { @@ -1538,7 +1543,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement tableProps.put(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_NAME, TRUE_BYTES_AS_STRING); TableDescriptor desc = ensureTableCreated(physicalIndexName, PTableType.TABLE, tableProps, families, splits, - false, isNamespaceMapped, false); + true, isNamespaceMapped, false); if (desc != null) { if (!Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(desc.getValue(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_BYTES)))) { String fullTableName = Bytes.toString(physicalIndexName); @@ -1861,7 +1866,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement private void dropTables(final List<byte[]> tableNamesToDelete) throws SQLException { SQLException sqlE = null; try (Admin admin = getAdmin()) { - if (tableNamesToDelete != null){ + if (tableNamesToDelete != null) { for ( byte[] tableName : tableNamesToDelete ) { try { TableName tn = TableName.valueOf(tableName);