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 e20edd6b7ba..b1178552400 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 @@ -2396,7 +2396,6 @@ private MetaDataMutationResult metaDataCoprocessorExec(String tableName, byte[] private MetaDataMutationResult metaDataCoprocessorExec(String tableName, byte[] tableKey, Batch.Call callable, byte[] systemTableName) throws SQLException { - Map results; try { boolean success = false; boolean retried = false; @@ -2410,10 +2409,12 @@ private MetaDataMutationResult metaDataCoprocessorExec(String tableName, byte[] Table ht = this.getTable(SchemaUtil.getPhysicalName(systemTableName, this.getProps()).getName()); try { - results = ht.coprocessorService(MetaDataService.class, tableKey, tableKey, callable); - - assert (results.size() == 1); - MetaDataResponse result = results.values().iterator().next(); + // The call goes to the one region that holds the table key, so it runs on the caller + // thread through a channel for that row. A region server handler can make this call, + // and the batch pool of the connection can be full of calls that wait for the same + // handlers. A call through that pool can then wait forever. + MetaDataResponse result = + callable.call(MetaDataService.newStub(ht.coprocessorService(tableKey))); if ( result.getReturnCode() == MetaDataProtos.MutationCode.TABLE_NOT_IN_REGION || result.getReturnCode() == MetaDataProtos.MutationCode.FUNCTION_NOT_IN_REGION