deniskuzZ commented on code in PR #4384:
URL: https://github.com/apache/hive/pull/4384#discussion_r1337112887


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -1047,36 +296,14 @@ public void cleanEmptyAbortedAndCommittedTxns() throws 
MetaException {
   @Override
   @RetrySemantics.Idempotent
   public void revokeFromLocalWorkers(String hostname) throws MetaException {
-    try {
-      Connection dbConn = null;
-      Statement stmt = null;
-      try {
-        dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED, 
connPoolCompaction);
-        stmt = dbConn.createStatement();
-        String s = "UPDATE \"COMPACTION_QUEUE\" SET \"CQ_WORKER_ID\" = NULL, 
\"CQ_START\" = NULL, \"CQ_STATE\" = '"
-          + INITIATED_STATE+ "' WHERE \"CQ_STATE\" = '" + WORKING_STATE + "' 
AND \"CQ_WORKER_ID\" LIKE '"
-          +  hostname + "%'";
-        LOG.debug("Going to execute update <{}>", s);
-        // It isn't an error if the following returns no rows, as the local 
workers could have died
-        // with  nothing assigned to them.
-        int updated = stmt.executeUpdate(s);
-        LOG.debug("Set {} compaction queue entries to {} state for host {}", 
updated, INITIATED_RESPONSE, hostname);
-        LOG.debug("Going to commit");
-        dbConn.commit();
-      } catch (SQLException e) {
-        LOG.error("Unable to change dead worker's records back to initiated 
state " +
-          e.getMessage());
-        LOG.debug("Going to rollback");
-        rollbackDBConn(dbConn);
-        checkRetryable(e, "revokeFromLocalWorkers(hostname:" + hostname +")");
-        throw new MetaException(DB_FAILED_TO_CONNECT + e.getMessage());
-      } finally {
-        closeStmt(stmt);
-        closeDbConn(dbConn);
-      }
-    } catch (RetryException e) {
-      revokeFromLocalWorkers(hostname);
-    }
+    jdbcResource.execute(
+        "UPDATE \"COMPACTION_QUEUE\" SET \"CQ_WORKER_ID\" = NULL, \"CQ_START\" 
= NULL," +

Review Comment:
   should we use `IS NULL` instead of `= NULL`



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -1047,36 +296,14 @@ public void cleanEmptyAbortedAndCommittedTxns() throws 
MetaException {
   @Override
   @RetrySemantics.Idempotent
   public void revokeFromLocalWorkers(String hostname) throws MetaException {
-    try {
-      Connection dbConn = null;
-      Statement stmt = null;
-      try {
-        dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED, 
connPoolCompaction);
-        stmt = dbConn.createStatement();
-        String s = "UPDATE \"COMPACTION_QUEUE\" SET \"CQ_WORKER_ID\" = NULL, 
\"CQ_START\" = NULL, \"CQ_STATE\" = '"
-          + INITIATED_STATE+ "' WHERE \"CQ_STATE\" = '" + WORKING_STATE + "' 
AND \"CQ_WORKER_ID\" LIKE '"
-          +  hostname + "%'";
-        LOG.debug("Going to execute update <{}>", s);
-        // It isn't an error if the following returns no rows, as the local 
workers could have died
-        // with  nothing assigned to them.
-        int updated = stmt.executeUpdate(s);
-        LOG.debug("Set {} compaction queue entries to {} state for host {}", 
updated, INITIATED_RESPONSE, hostname);
-        LOG.debug("Going to commit");
-        dbConn.commit();
-      } catch (SQLException e) {
-        LOG.error("Unable to change dead worker's records back to initiated 
state " +
-          e.getMessage());
-        LOG.debug("Going to rollback");
-        rollbackDBConn(dbConn);
-        checkRetryable(e, "revokeFromLocalWorkers(hostname:" + hostname +")");
-        throw new MetaException(DB_FAILED_TO_CONNECT + e.getMessage());
-      } finally {
-        closeStmt(stmt);
-        closeDbConn(dbConn);
-      }
-    } catch (RetryException e) {
-      revokeFromLocalWorkers(hostname);
-    }
+    jdbcResource.execute(
+        "UPDATE \"COMPACTION_QUEUE\" SET \"CQ_WORKER_ID\" = NULL, \"CQ_START\" 
= NULL," +

Review Comment:
   should we use `IS NULL` instead of `= NULL`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to