deniskuzZ commented on code in PR #4384:
URL: https://github.com/apache/hive/pull/4384#discussion_r1293071008
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -402,37 +141,12 @@ public CompactionInfo
findNextToCompact(FindNextCompactRequest rqst) throws Meta
@Override
@RetrySemantics.SafeToRetry
public void markCompacted(CompactionInfo info) 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_STATE\" = '" +
READY_FOR_CLEANING + "', "
- + "\"CQ_WORKER_ID\" = NULL"
- + " WHERE \"CQ_ID\" = " + info.id;
- LOG.debug("Going to execute update <{}>", s);
- int updCnt = stmt.executeUpdate(s);
- if (updCnt != 1) {
- LOG.error("Unable to set cq_state={} for compaction record: {}.
updCnt={}", READY_FOR_CLEANING, info, updCnt);
- LOG.debug("Going to rollback");
- dbConn.rollback();
- }
- LOG.debug("Going to commit");
- dbConn.commit();
- } catch (SQLException e) {
- LOG.error("Unable to update compaction queue " + e.getMessage());
- LOG.debug("Going to rollback");
- rollbackDBConn(dbConn);
- checkRetryable(e, "markCompacted(" + info + ")");
- throw new MetaException(DB_FAILED_TO_CONNECT + e.getMessage());
- } finally {
- closeStmt(stmt);
- closeDbConn(dbConn);
- }
- } catch (RetryException e) {
- markCompacted(info);
- }
+ ParameterizedCommand.execute(dataSourceWrapper,
Review Comment:
i like this style, would be even better if we declare jdbcTemplate embedding
dataSourceWrapper and exposing execute command
````
jdbcTemplate.execute(
"UPDATE \"COMPACTION_QUEUE\" SET \"CQ_STATE\" = :state, \"CQ_WORKER_ID\"
= NULL WHERE
\"CQ_ID\" = :id",
new MapSqlParameterSource()
.addValue("state", Character.toString(READY_FOR_CLEANING),
Types.CHAR)
.addValue("id", info.id),
ParameterizedCommand.EXACTLY_ONE_ROW))
````
--
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]