[ https://issues.apache.org/jira/browse/HIVE-26267?focusedWorklogId=777427&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-777427 ]
ASF GitHub Bot logged work on HIVE-26267: ----------------------------------------- Author: ASF GitHub Bot Created on: 02/Jun/22 11:38 Start Date: 02/Jun/22 11:38 Worklog Time Spent: 10m Work Description: veghlaci05 commented on code in PR #3325: URL: https://github.com/apache/hive/pull/3325#discussion_r887852145 ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java: ########## @@ -3701,122 +3698,125 @@ public CompactionResponse compact(CompactionRequest rqst) throws MetaException { * compactions for any resource. */ handle = getMutexAPI().acquireLock(MUTEX_KEY.CompactionScheduler.name()); - dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); - stmt = dbConn.createStatement(); - - long id = generateCompactionQueueId(stmt); - - GetValidWriteIdsRequest request = new GetValidWriteIdsRequest( - Collections.singletonList(getFullTableName(rqst.getDbname(), rqst.getTablename()))); - final ValidCompactorWriteIdList tblValidWriteIds = - TxnUtils.createValidCompactWriteIdList(getValidWriteIds(request).getTblValidWriteIds().get(0)); - LOG.debug("ValidCompactWriteIdList: " + tblValidWriteIds.writeToString()); - - List<String> params = new ArrayList<>(); - StringBuilder sb = new StringBuilder("SELECT \"CQ_ID\", \"CQ_STATE\" FROM \"COMPACTION_QUEUE\" WHERE"). - append(" (\"CQ_STATE\" IN("). - append(quoteChar(INITIATED_STATE)).append(",").append(quoteChar(WORKING_STATE)). - append(") OR (\"CQ_STATE\" = ").append(quoteChar(READY_FOR_CLEANING)). - append(" AND \"CQ_HIGHEST_WRITE_ID\" = ?))"). - append(" AND \"CQ_DATABASE\"=?"). - append(" AND \"CQ_TABLE\"=?").append(" AND "); - params.add(Long.toString(tblValidWriteIds.getHighWatermark())); - params.add(rqst.getDbname()); - params.add(rqst.getTablename()); - if(rqst.getPartitionname() == null) { - sb.append("\"CQ_PARTITION\" is null"); - } else { - sb.append("\"CQ_PARTITION\"=?"); - params.add(rqst.getPartitionname()); - } + try (Connection dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED)) { Review Comment: I have googled for it before splitting, and this approach was the suggested one. if you check the java [spec](https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.3.2), the extended try-with -resources construct is translated to a nested try-catch. The inner try-catch is responsible for closing the resources, so when the outer catch clause is executed (`dbConn.rollback();`), the connection object should be already closed. So as I understand, you cannot execute code in the catch/finally blocks which require the resource to be open. Did I miss something here? Issue Time Tracking ------------------- Worklog Id: (was: 777427) Time Spent: 1h 50m (was: 1h 40m) > Addendum to HIVE-26107: perpared statement is not working on Postgres > --------------------------------------------------------------------- > > Key: HIVE-26267 > URL: https://issues.apache.org/jira/browse/HIVE-26267 > Project: Hive > Issue Type: Bug > Reporter: László Végh > Assignee: László Végh > Priority: Major > Labels: pull-request-available > Time Spent: 1h 50m > Remaining Estimate: 0h > > The assembled prepared statement in > {code:java} > org.apache.hadoop.hive.metastore.txn.TxnHandler#compact{code} > does not work for Postgres DB. -- This message was sent by Atlassian Jira (v8.20.7#820007)