[ https://issues.apache.org/jira/browse/PHOENIX-6873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17687142#comment-17687142 ]
ASF GitHub Bot commented on PHOENIX-6873: ----------------------------------------- gjacoby126 commented on code in PR #1563: URL: https://github.com/apache/phoenix/pull/1563#discussion_r1102943974 ########## phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java: ########## @@ -90,26 +89,33 @@ public StoreFileReader preStoreFileReaderOpen(ObserverContext<RegionCoprocessorE RegionInfo childRegion = region.getRegionInfo(); byte[] splitKey = null; if (reader == null && r != null) { - if(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) { + if (!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) { return reader; } - PhoenixConnection conn = null; Table metaTable = null; byte[] regionStartKeyInHFile = null; - try (Connection hbaseConn = - ConnectionFactory.createConnection(ctx.getEnvironment().getConfiguration())) { + + try (PhoenixConnection conn = + QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()) + .unwrap(PhoenixConnection.class)) { + // This is the CQSI shared Connection. MUST NOT be closed. + Connection hbaseConn = conn.getQueryServices().getAdmin().getConnection(); Scan scan = CompatUtil.getScanForTableName(hbaseConn, tableName); SingleColumnValueFilter scvf = null; if (Reference.isTopFileRegion(r.getFileRegion())) { - scvf = new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, - HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, RegionInfoUtil.toByteArray(region.getRegionInfo())); + scvf = + new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, + HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, + RegionInfoUtil.toByteArray(region.getRegionInfo())); scvf.setFilterIfMissing(true); } else { - scvf = new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, - HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, RegionInfoUtil.toByteArray(region.getRegionInfo())); + scvf = + new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, + HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, + RegionInfoUtil.toByteArray(region.getRegionInfo())); scvf.setFilterIfMissing(true); } - if(scvf != null) scan.setFilter(scvf); + if (scvf != null) scan.setFilter(scvf); Review Comment: nit: checkstyle is warning on the 1-line if statement. ########## phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java: ########## @@ -90,26 +89,33 @@ public StoreFileReader preStoreFileReaderOpen(ObserverContext<RegionCoprocessorE RegionInfo childRegion = region.getRegionInfo(); byte[] splitKey = null; if (reader == null && r != null) { - if(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) { + if (!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) { return reader; } - PhoenixConnection conn = null; Table metaTable = null; byte[] regionStartKeyInHFile = null; - try (Connection hbaseConn = - ConnectionFactory.createConnection(ctx.getEnvironment().getConfiguration())) { + + try (PhoenixConnection conn = + QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()) + .unwrap(PhoenixConnection.class)) { + // This is the CQSI shared Connection. MUST NOT be closed. + Connection hbaseConn = conn.getQueryServices().getAdmin().getConnection(); Scan scan = CompatUtil.getScanForTableName(hbaseConn, tableName); SingleColumnValueFilter scvf = null; if (Reference.isTopFileRegion(r.getFileRegion())) { - scvf = new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, - HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, RegionInfoUtil.toByteArray(region.getRegionInfo())); + scvf = + new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, + HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, + RegionInfoUtil.toByteArray(region.getRegionInfo())); scvf.setFilterIfMissing(true); } else { - scvf = new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, - HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, RegionInfoUtil.toByteArray(region.getRegionInfo())); + scvf = + new SingleColumnValueFilter(HConstants.CATALOG_FAMILY, + HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, + RegionInfoUtil.toByteArray(region.getRegionInfo())); scvf.setFilterIfMissing(true); } - if(scvf != null) scan.setFilter(scvf); + if (scvf != null) scan.setFilter(scvf); Review Comment: It's also warning on the existing 1-line if statement on 186, which would be good to fix while we're at it. > Use cached Connection in IndexHalfStoreFileReaderGenerator > ---------------------------------------------------------- > > Key: PHOENIX-6873 > URL: https://issues.apache.org/jira/browse/PHOENIX-6873 > Project: Phoenix > Issue Type: Bug > Components: core > Reporter: Istvan Toth > Assignee: Istvan Toth > Priority: Major > > We use > org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(Configuration) > in > org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(Configuration) > . > While this is highly situational, this can also be a perf issue. > We are already opening a PhoenixConnection, we can the take the (H)Connection > from there, which solves all caching/pooling issues. -- This message was sent by Atlassian Jira (v8.20.10#820010)