[
https://issues.apache.org/jira/browse/PHOENIX-4870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604981#comment-16604981
]
ASF GitHub Bot commented on PHOENIX-4870:
-----------------------------------------
Github user karanmehta93 commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/338#discussion_r215431187
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixPreparedStatement.java
---
@@ -17,20 +17,20 @@
*/
package org.apache.phoenix.jdbc;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
+import java.sql.*;
public class LoggingPhoenixPreparedStatement extends
DelegatePreparedStatement {
private PhoenixMetricsLog phoenixMetricsLog;
private String sql;
+ private Connection conn;
- public LoggingPhoenixPreparedStatement(PreparedStatement stmt,
PhoenixMetricsLog phoenixMetricsLog, String sql) {
+ public LoggingPhoenixPreparedStatement(Connection conn,
PreparedStatement stmt,
+ PhoenixMetricsLog
phoenixMetricsLog, String sql) {
super(stmt);
this.phoenixMetricsLog = phoenixMetricsLog;
this.sql = sql;
+ this.conn = conn;
--- End diff --
nit: Can you move the init of variables in the same order as function
arguments?
> LoggingPhoenixConnection should log metrics when AutoCommit is set to True.
> ---------------------------------------------------------------------------
>
> Key: PHOENIX-4870
> URL: https://issues.apache.org/jira/browse/PHOENIX-4870
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.14.0
> Reporter: Swaroopa Kadam
> Assignee: Swaroopa Kadam
> Priority: Major
>
> When LoggingPhoenixConnection calls commit or close, metrics logs are written
> properly, however, when LoggingPhoenixConnection is explicitly set with
> AutoCommit as true, metrics don't get logged at all. This bug can also be
> tested by adding the following test scenario in PhoenixLoggingMetricsIT.java
> class.
> {code:java}
> @Test
> public void testPhoenixMetricsLoggedOnAutoCommit() throws Exception {
> // Autocommit is turned on explicitly
> loggedConn.setAutoCommit(true);
> //with executeUpdate() method
> // run SELECT to verify read metrics are logged
> String query = "SELECT * FROM " + tableName1;
> verifyQueryLevelMetricsLogging(query);
> // run UPSERT SELECT to verify mutation metrics are logged
> String upsertSelect = "UPSERT INTO " + tableName2 + " SELECT * FROM " +
> tableName1;
> loggedConn.createStatement().executeUpdate(upsertSelect);
> // Autocommit is turned on explicitly
> // Hence mutation metrics are expected during implicit commit
> assertTrue("Mutation write metrics are not logged for " + tableName2,
> mutationWriteMetricsMap.size() > 0);
> assertTrue("Mutation read metrics for not found for " + tableName1,
> mutationReadMetricsMap.get(tableName1).size() > 0);
> //with execute() method
> loggedConn.createStatement().execute(upsertSelect);
> // Autocommit is turned on explicitly
> // Hence mutation metrics are expected during implicit commit
> assertTrue("Mutation write metrics are not logged for " + tableName2,
> mutationWriteMetricsMap.size() > 0);
> assertTrue("Mutation read metrics for not found for " + tableName1,
> mutationReadMetricsMap.get(tableName1).size() > 0);
> clearAllTestMetricMaps();
> }
> {code}
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)