diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java index 230106f8acb..0d545f6c456 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java @@ -57,8 +57,6 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.RegionObserver; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; -import org.apache.hadoop.hbase.ipc.RpcControllerFactory; -import org.apache.hadoop.hbase.ipc.controller.InterRegionServerIndexRpcControllerFactory; import org.apache.hadoop.hbase.regionserver.InternalScanner; import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; import org.apache.hadoop.hbase.regionserver.Region; @@ -167,10 +165,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver private boolean isRegionClosingOrSplitting = false; private static final Logger LOGGER = LoggerFactory.getLogger(UngroupedAggregateRegionObserver.class); - private Configuration upsertSelectConfig; - private Configuration compactionConfig; - private Configuration indexWriteConfig; - private ReadOnlyProps indexWriteProps; + private Configuration envConfig; @Override public Optional getRegionObserver() { @@ -180,31 +175,20 @@ public Optional getRegionObserver() { @Override public void start(CoprocessorEnvironment e) throws IOException { /* - * We need to create a copy of region's configuration since we don't want any side effect of - * setting the RpcControllerFactory. + * Each open region has an instance of this coprocessor. A full configuration copy is large. + * Thus we keep only a reference to the environment configuration. Compaction and index write + * failure handling make their copy when they start, and they do not keep it. */ - upsertSelectConfig = PropertiesUtil.cloneConfig(e.getConfiguration()); - /* - * Till PHOENIX-3995 is fixed, we need to use the InterRegionServerIndexRpcControllerFactory. - * Although this would cause remote RPCs to use index handlers on the destination region - * servers, it is better than using the regular priority handlers which could result in a - * deadlock. - */ - upsertSelectConfig.setClass(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, - InterRegionServerIndexRpcControllerFactory.class, RpcControllerFactory.class); - - compactionConfig = ServerUtil.getCompactionConfig(e.getConfiguration()); + envConfig = e.getConfiguration(); + } + private Configuration getIndexWriteConfig() { // For retries of index write failures, use the same # of retries as the rebuilder - indexWriteConfig = PropertiesUtil.cloneConfig(e.getConfiguration()); + Configuration indexWriteConfig = PropertiesUtil.cloneConfig(envConfig); indexWriteConfig.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, - e.getConfiguration().getInt(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, + envConfig.getInt(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, QueryServicesOptions.DEFAULT_INDEX_REBUILD_RPC_RETRIES_COUNTER)); - indexWriteProps = new ReadOnlyProps(indexWriteConfig.iterator()); - } - - Configuration getUpsertSelectConfig() { - return upsertSelectConfig; + return indexWriteConfig; } void incrementScansReferenceCount() throws IOException { @@ -582,10 +566,11 @@ private void handleIndexWriteException(final List localRegionMutations PhoenixKeyValueUtil.setTimestamp(mutation, serverTimestamp); } IndexWriteException iwe = PhoenixIndexFailurePolicyHelper.getIndexWriteException(inferredE); + Configuration indexWriteConfig = getIndexWriteConfig(); try (PhoenixConnection conn = QueryUtil.getConnectionOnServer(indexWriteConfig).unwrap(PhoenixConnection.class)) { PhoenixIndexFailurePolicyHelper.doBatchWithRetries(mutateCommand, iwe, conn, - indexWriteProps); + new ReadOnlyProps(indexWriteConfig.iterator())); } catch (Exception e) { throw new DoNotRetryIOException(e); } @@ -646,6 +631,7 @@ public InternalScanner run() throws Exception { : tableName.getNameAsString(); PTable table = null; Long maxLookbackAge = null; + Configuration compactionConfig = ServerUtil.getCompactionConfig(envConfig); try (PhoenixConnection conn = QueryUtil.getConnectionOnServer(compactionConfig).unwrap(PhoenixConnection.class)) { table = conn.getTableNoCache(fullTableName);