diff --git metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 8597d9f..4a2c4f2 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -47,8 +47,9 @@ * A handler to answer transaction related calls that come into the metastore * server. * - * Note on log messages: Please include txnid:X and lockid info - * {@link org.apache.hadoop.hive.common.JavaUtils#lockIdToString(long)} in all messages. + * Note on log messages: Please include txnid:X and lockid info using + * {@link org.apache.hadoop.hive.common.JavaUtils#txnIdToString(long)} + * and {@link org.apache.hadoop.hive.common.JavaUtils#lockIdToString(long)} in all messages. * The txnid:X and lockid:Y matches how Thrift object toString() methods are generated, * so keeping the format consistent makes grep'ing the logs much easier. */ @@ -168,7 +169,8 @@ public GetOpenTxnsInfoResponse getOpenTxnsInfo() throws MetaException { } List txnInfo = new ArrayList(); - s = "select txn_id, txn_state, txn_user, txn_host from TXNS"; + //need the WHERE clause below to ensure consistent results with READ_COMMITTED + s = "select txn_id, txn_state, txn_user, txn_host from TXNS where txn_id <= " + hwm; LOG.debug("Going to execute query<" + s + ">"); rs = stmt.executeQuery(s); while (rs.next()) { @@ -232,7 +234,8 @@ public GetOpenTxnsResponse getOpenTxns() throws MetaException { } Set openList = new HashSet(); - s = "select txn_id from TXNS"; + //need the WHERE clause below to ensure consistent results with READ_COMMITTED + s = "select txn_id from TXNS where txn_id <= " + hwm; LOG.debug("Going to execute query<" + s + ">"); rs = stmt.executeQuery(s); while (rs.next()) { @@ -1461,7 +1464,7 @@ private LockResponse checkLock(Connection dbConn, LockResponse response = new LockResponse(); response.setLockid(extLockId); - LOG.debug("checkLock(): Setting savepoint. extLockId=" + extLockId); + LOG.debug("checkLock(): Setting savepoint. extLockId=" + JavaUtils.lockIdToString(extLockId)); Savepoint save = dbConn.setSavepoint(); StringBuilder query = new StringBuilder("select hl_lock_ext_id, " + "hl_lock_int_id, hl_db, hl_table, hl_partition, hl_lock_state, " + @@ -1687,7 +1690,7 @@ private void acquire(Connection dbConn, Statement stmt, long extLockId, long int if (rc < 1) { LOG.debug("Going to rollback"); dbConn.rollback(); - throw new NoSuchLockException("No such lock: (" + extLockId + "," + + throw new NoSuchLockException("No such lock: (" + JavaUtils.lockIdToString(extLockId) + "," + + intLockId + ")"); } // We update the database, but we don't commit because there may be other @@ -1712,7 +1715,7 @@ private void heartbeatLock(Connection dbConn, long extLockId) if (rc < 1) { LOG.debug("Going to rollback"); dbConn.rollback(); - throw new NoSuchLockException("No such lock: " + extLockId); + throw new NoSuchLockException("No such lock: " + JavaUtils.lockIdToString(extLockId)); } LOG.debug("Going to commit"); dbConn.commit();