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

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


The following commit(s) were added to refs/heads/master by this push:
     new 42d9546161 PHOENIX-5534 - Cursors With Request Metrics Enabled Throws 
Exception (#1451)
42d9546161 is described below

commit 42d95461618f1774fef13ecdb2d58bdd0bfedc7e
Author: Geoffrey Jacoby <gjac...@salesforce.com>
AuthorDate: Wed Jun 15 11:35:49 2022 -0400

    PHOENIX-5534 - Cursors With Request Metrics Enabled Throws Exception (#1451)
---
 .../main/java/org/apache/phoenix/monitoring/OverAllQueryMetrics.java  | 4 +++-
 .../src/test/java/org/apache/phoenix/compile/CursorCompilerTest.java  | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/OverAllQueryMetrics.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/OverAllQueryMetrics.java
index 648ae97c8b..5038cb3238 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/OverAllQueryMetrics.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/OverAllQueryMetrics.java
@@ -107,7 +107,9 @@ public class OverAllQueryMetrics {
     }
 
     public void startQuery() {
-        queryWatch.start();
+        if (!queryWatch.isRunning()) {
+            queryWatch.start();
+        }
     }
 
     public void endQuery() {
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/compile/CursorCompilerTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/compile/CursorCompilerTest.java
index a8f37f0535..2fd99cb91f 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/compile/CursorCompilerTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/compile/CursorCompilerTest.java
@@ -68,6 +68,10 @@ public class CursorCompilerTest extends 
BaseConnectionlessQueryTest {
         String query = "SELECT a_string, b_string FROM atable";
         String sql = "DECLARE testCursor CURSOR FOR " + query;
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        //this verifies PHOENIX-5534 is fixed and we don't initialize metrics 
twice
+        //on a cursor query
+        props.put("phoenix.query.request.metrics.enabled","true");
+
         Connection conn = DriverManager.getConnection(getUrl(), props);
         //Test declare cursor compile
         PreparedStatement statement = conn.prepareStatement(sql);

Reply via email to