simhadri-g commented on code in PR #3307:
URL: https://github.com/apache/hive/pull/3307#discussion_r898344710


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java:
##########
@@ -5297,6 +5303,28 @@ is performed on that db (e.g. show tables, created 
table, etc).
             return response;
           }
         }
+
+        if (checkForConcurrentCtas && isValidTxn(txnId)) {
+          LockType lockType = LockTypeUtil.getLockTypeFromEncoding(lockChar)
+                  .orElseThrow(() -> new MetaException("Unknown lock type: " + 
lockChar));
+
+          if (lockType == LockType.EXCL_WRITE && blockedBy.state == 
LockState.ACQUIRED) {
+
+            String deleteBlockedByTxnComp = "DELETE  FROM \"TXN_COMPONENTS\" 
WHERE" + " \"TC_TXNID\"=" + txnId;

Review Comment:
   No, txn abort still leaves behind entries in TXN_COMPONENTS . 
   This happens even when an insert query is aborted. Looks like a bug.
   
   Below TXN_ID = 2  was aborted. But TXN_COMPONENTS still has entry.
   ```
   mysql> select * from TXNS;
   
+--------+-----------+---------------+--------------------+----------+-----------+----------------+---------------+---------------------+----------+
   | TXN_ID | TXN_STATE | TXN_STARTED   | TXN_LAST_HEARTBEAT | TXN_USER | 
TXN_HOST  | TXN_AGENT_INFO | TXN_META_INFO | TXN_HEARTBEAT_COUNT | TXN_TYPE |
   
+--------+-----------+---------------+--------------------+----------+-----------+----------------+---------------+---------------------+----------+
   |      0 | c         |             0 |                  0 |          |       
    | NULL           | NULL          |                NULL |     NULL |
   |      1 | c         | 1655320638716 |      1655320638716 | hive     | 
localhost | NULL           | NULL          |                NULL |        0 |
   |      2 | a         | 1655320644989 |      1655320664896 | hive     | 
localhost | NULL           | NULL          |                NULL |        0 |
   |      3 | c         | 1655320688403 |      1655320688403 | hive     | 
localhost | NULL           | NULL          |                NULL |        0 |
   |      4 | c         | 1655320719660 |      1655320719660 | hive     | 
localhost | NULL           | NULL          |                NULL |        0 |
   
   
   mysql> select * from TXN_COMPONENTS;
   
+----------+-------------+----------+--------------+-------------------+------------+
   | TC_TXNID | TC_DATABASE | TC_TABLE | TC_PARTITION | TC_OPERATION_TYPE | 
TC_WRITEID |
   
+----------+-------------+----------+--------------+-------------------+------------+
   |        2 | default     | t1       | NULL         | i                 |     
     1 |
   
+----------+-------------+----------+--------------+-------------------+------------+
   1 row in set (0.00 sec)
   ```



-- 
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]

Reply via email to