From 9a2762806f74804e5a47d114328240c676ff11a3 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Fri, 4 Dec 2026 11:40:51 -0800 Subject: [PATCH 1/2] PHOENIX-8121 Deadlock between index metadata lookups and the server connection pool metaDataCoprocessorExec read one row of a system table with the range form of Table.coprocessorService. HBase runs each region call of that form as a task in the batch pool of the connection, and the caller waits for the task without a timeout. On a region server, write handlers make this call when the index metadata of a batch comes from the server. The batch pool of the server connection is bounded. Its threads can hold scans that wait in the default call queue for the same handlers. Then neither side makes progress, and the region server stops serving writes. The call now uses the single-row coprocessor channel and runs on the caller thread. The channel call is the same call that the pool task made, with the same operation timeout and retries, so results and errors do not change. The call does not wait for a pool thread. Co-Authored-By: Claude Opus 5.5 --- .../phoenix/query/ConnectionQueryServicesImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 e20edd6b7ba..566d80481a7 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,11 @@ 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 reads one row, 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. + 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 From a29e2c8d90579509b6aebfd6ba746d81a46f3ffa Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Fri, 4 Dec 2026 12:44:12 -0800 Subject: [PATCH 2/2] PHOENIX-8121 Explain why the metadata call runs on the caller thread The call goes to the one region that holds the table key. The comment now says this, and it says what happens when the call goes through the batch pool of the connection instead. Co-Authored-By: Claude Opus 5.5 --- .../apache/phoenix/query/ConnectionQueryServicesImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 566d80481a7..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 @@ -2409,9 +2409,10 @@ private MetaDataMutationResult metaDataCoprocessorExec(String tableName, byte[] Table ht = this.getTable(SchemaUtil.getPhysicalName(systemTableName, this.getProps()).getName()); try { - // The call reads one row, 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. + // 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 (