From 6aea018b13d3c6db332618b41a90cac61e629e14 Mon Sep 17 00:00:00 2001 From: zsj Date: Thu, 21 Jun 2018 16:10:13 +0800 Subject: [PATCH] patch for: https://issues.apache.org/jira/browse/HIVE-19950 --- .../org/apache/hadoop/hive/metastore/txn/TxnHandler.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 361ede54ef..4bc21aaae8 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -3704,6 +3704,11 @@ private LockResponse checkLock(Connection dbConn, long extLockId) continue; } + //skip check conflict with lock of the same transaction + if (info.txnId == locks[i].txnId){ + continue; + } + // We've found something that matches what we're trying to lock, // so figure out if we can lock it too. LockAction lockAction = jumpTable.get(info.type).get(locks[i].type).get(locks[i].state); @@ -3716,7 +3721,7 @@ private LockResponse checkLock(Connection dbConn, long extLockId) * this (metastore db) transaction and then we record which lock blocked the lock * we were testing ('info').*/ wait(dbConn, save); - String sqlText = "update HIVE_LOCKS" + + /*String sqlText = "update HIVE_LOCKS" + " set HL_BLOCKEDBY_EXT_ID=" + locks[i].extLockId + ", HL_BLOCKEDBY_INT_ID=" + locks[i].intLockId + " where HL_LOCK_EXT_ID=" + info.extLockId + " and HL_LOCK_INT_ID=" + info.intLockId; @@ -3724,7 +3729,14 @@ private LockResponse checkLock(Connection dbConn, long extLockId) int updCnt = stmt.executeUpdate(sqlText); if(updCnt != 1) { shouldNeverHappen(info.txnId, info.extLockId, info.intLockId); - } + }*/ + + String deleteText = "delete from HIVE_LOCKS " + + " where HL_LOCK_EXT_ID=" + info.extLockId + " and HL_LOCK_INT_ID=" + info.intLockId + + " and HL_TXNID=" + info.txnId; + LOG.debug("Going to execute: {}", deleteText); + stmt.execute(deleteText); + LOG.debug("Going to commit"); dbConn.commit(); response.setState(LockState.WAITING); -- 2.16.3