You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2019/05/03 21:17:15 UTC
[phoenix] branch 4.14-HBase-1.4 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.14-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.14-HBase-1.4 by this push:
new 27e08f1 PHOENIX-5101 ScanningResultIterator getScanMetrics throws NPE
27e08f1 is described below
commit 27e08f1d7858ccde2888c761e98568070026cfa5
Author: Thomas D'Silva <td...@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();