This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.14-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.14-HBase-1.3 by this push: new 3e34ebe PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE 3e34ebe is described below commit 3e34ebee308101564b23bdd227178e28617520ca Author: Thomas D'Silva <tdsi...@apache.org> 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 0882cec..923673b 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 8a1fe5a..f4bbbf1 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();