Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2192018EB2 for ; Thu, 1 Oct 2015 00:42:50 +0000 (UTC) Received: (qmail 6467 invoked by uid 500); 1 Oct 2015 00:42:50 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 6350 invoked by uid 500); 1 Oct 2015 00:42:50 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 6158 invoked by uid 99); 1 Oct 2015 00:42:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2015 00:42:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 91894E0A31; Thu, 1 Oct 2015 00:42:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ekoifman@apache.org To: commits@hive.apache.org Date: Thu, 01 Oct 2015 00:42:50 -0000 Message-Id: <0a966935da62429f81c0a51242cbfe68@git.apache.org> In-Reply-To: <7d344e09b1414c9b91e7545e606e81b7@git.apache.org> References: <7d344e09b1414c9b91e7545e606e81b7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] hive git commit: HIVE-11916 TxnHandler.getOpenTxnsInfo() and getOpenTxns() may produce inconsistent result (Eugene Koifman, reviewed by Ashutosh Chauhan) HIVE-11916 TxnHandler.getOpenTxnsInfo() and getOpenTxns() may produce inconsistent result (Eugene Koifman, reviewed by Ashutosh Chauhan) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/43e08a4e Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/43e08a4e Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/43e08a4e Branch: refs/heads/branch-1 Commit: 43e08a4ee1ddddfd6d9c718341ee2e8a49d56818 Parents: 6a91134 Author: Eugene Koifman Authored: Wed Sep 30 17:19:01 2015 -0700 Committer: Eugene Koifman Committed: Wed Sep 30 17:19:01 2015 -0700 ---------------------------------------------------------------------- .../hadoop/hive/metastore/txn/TxnHandler.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/43e08a4e/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java ---------------------------------------------------------------------- diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index aa8bf8a..82f0dc0 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -47,8 +47,9 @@ import java.util.concurrent.TimeUnit; * 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. */ @@ -166,7 +167,8 @@ public class TxnHandler { } 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()) { @@ -230,7 +232,8 @@ public class TxnHandler { } 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()) { @@ -1459,7 +1462,7 @@ public class TxnHandler { 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, " + @@ -1685,7 +1688,7 @@ public class TxnHandler { 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 @@ -1710,7 +1713,7 @@ public class TxnHandler { 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();