[ 
https://issues.apache.org/jira/browse/HIVE-25346?focusedWorklogId=666797&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-666797
 ]

ASF GitHub Bot logged work on HIVE-25346:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Oct/21 08:46
            Start Date: 19/Oct/21 08:46
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on a change in pull request #2716:
URL: https://github.com/apache/hive/pull/2716#discussion_r731633760



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -1617,42 +1625,52 @@ private boolean isUpdateOrDelete(Statement stmt, String 
conflictSQLSuffix) throw
    * @return max Id for the conflicting transaction, if any, otherwise -1
    * @throws MetaException
    */
+  @RetrySemantics.ReadOnly
   public long getLatestTxnIdInConflict(long txnid) throws MetaException {
-    Connection dbConn = null;
-    Statement stmt = null;
-
     try {
-      dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
-      stmt = dbConn.createStatement();
+      Connection dbConn = null;
+      Statement stmt = null;
 
-      String writeConflictQuery = "SELECT MAX(\"COMMITTED\".\"WS_TXNID\")" +
-        " FROM \"WRITE_SET\" \"COMMITTED\" " +
-        "   INNER JOIN (" +
-        "SELECT DISTINCT \"TC_DATABASE\", \"TC_TABLE\", \"TC_PARTITION\", 
\"TC_TXNID\" " +
-        " FROM \"TXN_COMPONENTS\"  " +
-        "   WHERE \"TC_TXNID\" = " + txnid +
-        "     AND \"TC_OPERATION_TYPE\" IN (" + OperationType.UPDATE + "," + 
OperationType.DELETE + ")) \"CUR\" " +
-        "   ON \"COMMITTED\".\"WS_DATABASE\" = \"CUR\".\"TC_DATABASE\" " +
-        "     AND \"COMMITTED\".\"WS_TABLE\" = \"CUR\".\"TC_TABLE\" " +
-        //For partitioned table we always track writes at partition level 
(never at table)
-        //and for non partitioned - always at table level, thus the same table 
should never
-        //have entries with partition key and w/o
-        "     AND (\"COMMITTED\".\"WS_PARTITION\" = \"CUR\".\"TC_PARTITION\" 
OR " +
-        "       \"CUR\".\"TC_PARTITION\" IS NULL) " +
-        " WHERE \"CUR\".\"TC_TXNID\" <= \"COMMITTED\".\"WS_COMMIT_ID\""; 
//txns overlap
-
-      LOG.debug("Going to execute query: <" + writeConflictQuery + ">");
-      ResultSet rs = stmt.executeQuery(writeConflictQuery);
-      return rs.next() ? rs.getLong(1) : -1;
-
-    } catch (Exception e) {
-      throw new MetaException(StringUtils.stringifyException(e));
+      try {

Review comment:
       however, that would introduce few more levels of nesting: +2




-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 666797)
    Time Spent: 12h 50m  (was: 12h 40m)

> cleanTxnToWriteIdTable breaks SNAPSHOT isolation
> ------------------------------------------------
>
>                 Key: HIVE-25346
>                 URL: https://issues.apache.org/jira/browse/HIVE-25346
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Chovan
>            Assignee: Denys Kuzmenko
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 12h 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to