[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE
This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new df62802 PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE df62802 is described below commit df62802cb0d53c990821a365223819fc3f170e7c Author: Thomas D'Silva AuthorDate: Thu May 2 16:33:20 2019 -0700 PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE --- .../org/apache/phoenix/monitoring/PhoenixMetricsIT.java | 16 .../apache/phoenix/iterate/ScanningResultIterator.java | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java index 9dddece..74e69f6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java @@ -212,6 +212,22 @@ public class PhoenixMetricsIT extends BasePhoenixMetricsIT { conn.createStatement().execute(ddl); } +// See PHOENIX-5101 +@Test +public void testMetricsLargeQuery() throws Exception { +String tableName = "MY_TABLE"; +String ddl = "CREATE TABLE " + tableName + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; +Connection conn = DriverManager.getConnection(getUrl()); +conn.createStatement().execute(ddl); +long numRows = 18750; +insertRowsInTable(tableName, numRows); +String query = "SELECT * FROM " + tableName; +Statement stmt = conn.createStatement(); +ResultSet rs = stmt.executeQuery(query); +while (rs.next()) {} +rs.close(); +} + @Test public void testReadMetricsForSelect() throws Exception { String tableName = generateUniqueName(); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java index 1422455..1a3d073 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java @@ -77,8 +77,9 @@ public class ScanningResultIterator implements ResultIterator { @Override public void close() throws SQLException { -getScanMetrics(); +// close the scanner so that metrics are available scanner.close(); +updateMetrics(); } private void changeMetric(CombinableMetric metric, Long value) { @@ -93,7 +94,7 @@ public class ScanningResultIterator implements ResultIterator { } } -private void getScanMetrics() { +private void updateMetrics() { if (scanMetricsEnabled && !scanMetricsUpdated) { ScanMetrics scanMetrics = scan.getScanMetrics();
[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE (Addendum)
This is an automated email from the ASF dual-hosted git repository. karanmehta93 pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new ac2fbbf PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE (Addendum) ac2fbbf is described below commit ac2fbbf12d839dfdabe295342e1a1f2767a8ceb9 Author: Karan Mehta AuthorDate: Wed Apr 3 15:13:50 2019 -0700 PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE (Addendum) --- .../phoenix/iterate/ScanningResultIterator.java| 25 +- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java index 9a656ee..1422455 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java @@ -17,15 +17,6 @@ */ package org.apache.phoenix.iterate; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.BYTES_IN_REMOTE_RESULTS_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.BYTES_IN_RESULTS_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.MILLIS_BETWEEN_NEXTS_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.NOT_SERVING_REGION_EXCEPTION_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REGIONS_SCANNED_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REMOTE_RPC_CALLS_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REMOTE_RPC_RETRIES_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.RPC_CALLS_METRIC_NAME; -import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.RPC_RETRIES_METRIC_NAME; import static org.apache.hadoop.hbase.client.metrics.ServerSideScanMetrics.COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME; import static org.apache.hadoop.hbase.client.metrics.ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_IN_REMOTE_RESULTS; @@ -59,12 +50,26 @@ import org.apache.phoenix.util.ServerUtil; public class ScanningResultIterator implements ResultIterator { private final ResultScanner scanner; +private final Scan scan; private final ScanMetricsHolder scanMetricsHolder; boolean scanMetricsUpdated; boolean scanMetricsEnabled; +// These metric names are how HBase refers them +// Since HBase stores these strings as static final, we are using the same here +static final String RPC_CALLS_METRIC_NAME = "RPC_CALLS"; +static final String REMOTE_RPC_CALLS_METRIC_NAME = "REMOTE_RPC_CALLS"; +static final String MILLIS_BETWEEN_NEXTS_METRIC_NAME = "MILLIS_BETWEEN_NEXTS"; +static final String NOT_SERVING_REGION_EXCEPTION_METRIC_NAME = "NOT_SERVING_REGION_EXCEPTION"; +static final String BYTES_IN_RESULTS_METRIC_NAME = "BYTES_IN_RESULTS"; +static final String BYTES_IN_REMOTE_RESULTS_METRIC_NAME = "BYTES_IN_REMOTE_RESULTS"; +static final String REGIONS_SCANNED_METRIC_NAME = "REGIONS_SCANNED"; +static final String RPC_RETRIES_METRIC_NAME = "RPC_RETRIES"; +static final String REMOTE_RPC_RETRIES_METRIC_NAME = "REMOTE_RPC_RETRIES"; + public ScanningResultIterator(ResultScanner scanner, Scan scan, ScanMetricsHolder scanMetricsHolder) { this.scanner = scanner; +this.scan = scan; this.scanMetricsHolder = scanMetricsHolder; scanMetricsUpdated = false; scanMetricsEnabled = scan.isScanMetricsEnabled(); @@ -91,7 +96,7 @@ public class ScanningResultIterator implements ResultIterator { private void getScanMetrics() { if (scanMetricsEnabled && !scanMetricsUpdated) { -ScanMetrics scanMetrics = scanner.getScanMetrics(); +ScanMetrics scanMetrics = scan.getScanMetrics(); Map scanMetricsMap = scanMetrics.getMetricsMap(); scanMetricsHolder.setScanMetricMap(scanMetricsMap);
[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE
This is an automated email from the ASF dual-hosted git repository. karanmehta93 pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new b03f84f PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE b03f84f is described below commit b03f84f318b4f37197a3a85273db8b1afe6246ce Author: Karan Mehta AuthorDate: Wed Apr 3 11:34:26 2019 -0700 PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE --- .../phoenix/iterate/ScanningResultIterator.java| 85 -- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java index 893eaa2..9a656ee 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java @@ -17,6 +17,17 @@ */ package org.apache.phoenix.iterate; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.BYTES_IN_REMOTE_RESULTS_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.BYTES_IN_RESULTS_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.MILLIS_BETWEEN_NEXTS_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.NOT_SERVING_REGION_EXCEPTION_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REGIONS_SCANNED_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REMOTE_RPC_CALLS_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.REMOTE_RPC_RETRIES_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.RPC_CALLS_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ScanMetrics.RPC_RETRIES_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ServerSideScanMetrics.COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME; +import static org.apache.hadoop.hbase.client.metrics.ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_IN_REMOTE_RESULTS; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS; @@ -40,6 +51,7 @@ import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.metrics.ScanMetrics; import org.apache.phoenix.monitoring.CombinableMetric; +import org.apache.phoenix.monitoring.GlobalClientMetrics; import org.apache.phoenix.monitoring.ScanMetricsHolder; import org.apache.phoenix.schema.tuple.ResultTuple; import org.apache.phoenix.schema.tuple.Tuple; @@ -47,29 +59,12 @@ import org.apache.phoenix.util.ServerUtil; public class ScanningResultIterator implements ResultIterator { private final ResultScanner scanner; -private final Scan scan; private final ScanMetricsHolder scanMetricsHolder; boolean scanMetricsUpdated; boolean scanMetricsEnabled; -// These metric names are how HBase refers them -// Since HBase stores these strings as static final, we are using the same here -static final String RPC_CALLS_METRIC_NAME = "RPC_CALLS"; -static final String REMOTE_RPC_CALLS_METRIC_NAME = "REMOTE_RPC_CALLS"; -static final String MILLIS_BETWEEN_NEXTS_METRIC_NAME = "MILLIS_BETWEEN_NEXTS"; -static final String NOT_SERVING_REGION_EXCEPTION_METRIC_NAME = "NOT_SERVING_REGION_EXCEPTION"; -static final String BYTES_IN_RESULTS_METRIC_NAME = "BYTES_IN_RESULTS"; -static final String BYTES_IN_REMOTE_RESULTS_METRIC_NAME = "BYTES_IN_REMOTE_RESULTS"; -static final String REGIONS_SCANNED_METRIC_NAME = "REGIONS_SCANNED"; -static final String RPC_RETRIES_METRIC_NAME = "RPC_RETRIES"; -static final String REMOTE_RPC_RETRIES_METRIC_NAME = "REMOTE_RPC_RETRIES"; -static final String COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME = "ROWS_SCANNED"; -static final String COUNT_OF_ROWS_FILTERED_KEY_METRIC_NAME = "ROWS_FILTERED"; -static final String GLOBAL_BYTES_IN_RESULTS_METRIC_NAME = "BYTES_IN_RESULTS"; - public ScanningResultIterator(ResultScanner scanner, Scan scan, ScanMetricsHolder scanMetricsHolder) { this.scanner = scanner; -this.scan = scan; this.scanMetricsHolder = scanMetricsHolder; scanMetricsUpdated = false; scanMetricsEnabled = scan.isScanMetricsEnabled(); @@ -81,24 +76,25 @@ public class ScanningResultIterator implements ResultIterator { scanner.close(); } -private static void changeMetric(CombinableMetric metric, Long value) { +private void chang