veghlaci05 commented on code in PR #4384:
URL: https://github.com/apache/hive/pull/4384#discussion_r1310023851
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java:
##########
@@ -3645,6 +3678,38 @@ long generateCompactionQueueId(Statement stmt) throws
SQLException, MetaExceptio
}
}
+ long generateCompactionQueueId() throws MetaException {
+ // Get the id for the next entry in the queue
+ String sql = sqlGenerator.addForUpdateClause("SELECT \"NCQ_NEXT\" FROM
\"NEXT_COMPACTION_QUEUE_ID\"");
Review Comment:
No, it's executed in the same. The `TransactionStatus` and the
`RetryContext` are stored in `ThreadLocal`, so they are accessible throughout
the execution until a commit/rollback happens.
`jdbcTemplate.getJdbcTemplate() `will access the same connection as the
caller did/will.
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java:
##########
@@ -5695,24 +5759,18 @@ private List<LockInfo> getLocksFromLockId(Connection
dbConn, long extLockId) thr
// for read-only autoCommit=true statements. This does a commit,
// and thus should be done before any calls to heartbeat that will leave
// open transactions.
- private void timeOutLocks(Connection dbConn) {
- Set<Long> timedOutLockIds = new TreeSet<>();
+ private void timeOutLocks() {
//doing a SELECT first is less efficient but makes it easier to debug
things
//when txnid is <> 0, the lock is associated with a txn and is handled by
performTimeOuts()
//want to avoid expiring locks for a txn w/o expiring the txn itself
- try (PreparedStatement pstmt = dbConn.prepareStatement(
- String.format(SELECT_TIMED_OUT_LOCKS_QUERY,
getEpochFn(dbProduct)))) {
- pstmt.setLong(1, timeout);
- LOG.debug("Going to execute query: <{}>", SELECT_TIMED_OUT_LOCKS_QUERY);
- try (ResultSet rs = pstmt.executeQuery()) {
- while (rs.next()) {
- timedOutLockIds.add(rs.getLong(1));
- }
- dbConn.commit();
- if (timedOutLockIds.isEmpty()) {
- LOG.debug("Did not find any timed-out locks, therefore retuning.");
- return;
- }
+ try {
+ Set<Long> timedOutLockIds = new TreeSet<>(
+
jdbcTemplate.getJdbcTemplate().query(String.format(SELECT_TIMED_OUT_LOCKS_QUERY,
getEpochFn(dbProduct)),
Review Comment:
same as above
--
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]