You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2023/02/10 18:50:33 UTC

[phoenix] branch 5.1 updated: PHOENIX-6872 Use ServerUtil.getConnection() in UngroupedAggregateRegionScanner

This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.1 by this push:
     new 67d3eda494 PHOENIX-6872 Use ServerUtil.getConnection() in UngroupedAggregateRegionScanner
67d3eda494 is described below

commit 67d3eda4943f0343fed2cbbdf3183cfd78a55312
Author: Istvan Toth <st...@apache.org>
AuthorDate: Fri Feb 10 13:04:11 2023 +0100

    PHOENIX-6872 Use ServerUtil.getConnection() in UngroupedAggregateRegionScanner
---
 .../UngroupedAggregateRegionScanner.java           | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
index ccf435e5f7..25ad562cc3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
@@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.CellBuilderFactory;
 import org.apache.hadoop.hbase.CellBuilderType;
 import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Mutation;
 import org.apache.hadoop.hbase.client.Put;
@@ -78,7 +79,6 @@ import org.apache.phoenix.hbase.index.util.GenericKeyValueBuilder;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.index.IndexMaintainer;
 import org.apache.phoenix.index.PhoenixIndexCodec;
-import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.memory.InsufficientMemoryException;
 import org.apache.phoenix.memory.MemoryManager;
 import org.apache.phoenix.query.QueryConstants;
@@ -113,7 +113,6 @@ import org.apache.phoenix.util.ExpressionUtil;
 import org.apache.phoenix.util.IndexUtil;
 import org.apache.phoenix.util.LogUtil;
 import org.apache.phoenix.util.PhoenixKeyValueUtil;
-import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.ServerUtil;
 import org.apache.phoenix.util.StringUtil;
@@ -162,7 +161,6 @@ public class UngroupedAggregateRegionScanner extends BaseRegionScanner {
     private boolean incrScanRefCount = false;
     private byte[] indexMaintainersPtr;
     private boolean useIndexProto;
-    private PhoenixConnection targetPConn = null;
 
     public UngroupedAggregateRegionScanner(final ObserverContext<RegionCoprocessorEnvironment> c,
                                            final RegionScanner innerScanner, final Region region, final Scan scan,
@@ -228,13 +226,10 @@ public class UngroupedAggregateRegionScanner extends BaseRegionScanner {
         if (upsertSelectTable != null) {
             isUpsert = true;
             projectedTable = deserializeTable(upsertSelectTable);
-            targetPConn =
-                    ((PhoenixConnection) QueryUtil.getConnectionOnServer(
-                        ungroupedAggregateRegionObserver.getUpsertSelectConfig()));
-            targetHTable =
-                    targetPConn.getQueryServices()
-                            .getTable(projectedTable.getPhysicalName().getBytes());
-            // TODO Can't we just close the PhoenixConnection immediately here ?
+            //The Connection is a singleton. It MUST NOT be closed.
+            targetHTable = ServerUtil.ConnectionFactory.getConnection(
+                ServerUtil.ConnectionType.DEFAULT_SERVER_CONNECTION,
+                env).getTable(TableName.valueOf(projectedTable.getPhysicalName().getBytes()));
             selectExpressions = deserializeExpressions(scan.getAttribute(BaseScannerRegionObserver.UPSERT_SELECT_EXPRS));
             values = new byte[projectedTable.getPKColumns().size()][];
             isPKChanging = ExpressionUtil.isPkPositionChanging(new TableRef(projectedTable), selectExpressions);
@@ -314,13 +309,6 @@ public class UngroupedAggregateRegionScanner extends BaseRegionScanner {
                     LOGGER.error("Closing table: " + targetHTable + " failed: ", e);
                 }
             }
-            if (targetPConn != null) {
-                try {
-                    targetPConn.close();
-                } catch (SQLException e) {
-                    LOGGER.error("Closing connection: " + targetPConn + " failed: ", e);
-                }
-            }
         } finally {
             innerScanner.close();
         }