veghlaci05 commented on code in PR #4384:
URL: https://github.com/apache/hive/pull/4384#discussion_r1309963653
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java:
##########
@@ -882,24 +926,15 @@ public void setOpenTxnTimeOutMillis(long
openTxnTimeOutMillis) {
TxnHandler.openTxnTimeOutMillis = openTxnTimeOutMillis;
}
- protected long getOpenTxnTimeoutLowBoundaryTxnId(Connection dbConn) throws
MetaException, SQLException {
- long maxTxnId;
- String s =
- "SELECT MAX(\"TXN_ID\") FROM \"TXNS\" WHERE \"TXN_STARTED\" < (" +
getEpochFn(dbProduct) + " - "
- + openTxnTimeOutMillis + ")";
- try (Statement stmt = dbConn.createStatement()) {
- LOG.debug("Going to execute query <{}>", s);
- try (ResultSet maxTxnIdRs = stmt.executeQuery(s)) {
- maxTxnIdRs.next();
- maxTxnId = maxTxnIdRs.getLong(1);
- if (maxTxnIdRs.wasNull()) {
- /*
- * TXNS always contains at least one transaction,
- * the row where txnid = (select max(txnid) where txn_started <
epoch - TXN_OPENTXN_TIMEOUT) is never deleted
- */
- throw new MetaException("Transaction tables not properly " +
"initialized, null record found in MAX(TXN_ID)");
- }
- }
+ protected long getOpenTxnTimeoutLowBoundaryTxnId() throws MetaException {
+ Long maxTxnId = jdbcTemplate.getJdbcTemplate().queryForObject("SELECT
MAX(\"TXN_ID\") FROM \"TXNS\" WHERE \"TXN_STARTED\" < (" +
getEpochFn(dbProduct) + " - "
Review Comment:
JdbcTemplate works the following way:
- if we are inside a transaction, the associated connection (and
transaction) will be used for all jdbctemplate calls.
- If we are not in a transaction the call is considered a single
transactional call: a connection and trasaction is obtained, then released.
this method called from two places, both initiated a txn before, so we are
reusing the connection as before.
--
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]