hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carl Steinbach (JIRA)" <j...@apache.org>
Subject [jira] Created: (HIVE-1681) ObjectStore.commitTransaction() does not properly handle transactions that have already been rolled back
Date Fri, 01 Oct 2010 08:31:33 GMT
ObjectStore.commitTransaction() does not properly handle transactions that have already been
rolled back
--------------------------------------------------------------------------------------------------------

                 Key: HIVE-1681
                 URL: https://issues.apache.org/jira/browse/HIVE-1681
             Project: Hadoop Hive
          Issue Type: Bug
          Components: Metastore
    Affects Versions: 0.5.0, 0.6.0, 0.7.0
            Reporter: Carl Steinbach
            Assignee: Carl Steinbach


Here's the code for ObjectStore.commitTransaction() and ObjectStore.rollbackTransaction():

{code}
  public boolean commitTransaction() {
    assert (openTrasactionCalls >= 1);
    if (!currentTransaction.isActive()) {
      throw new RuntimeException(
          "Commit is called, but transaction is not active. Either there are"
              + " mismatching open and close calls or rollback was called in the same trasaction");
    }
    openTrasactionCalls--;
    if ((openTrasactionCalls == 0) && currentTransaction.isActive()) {
      transactionStatus = TXN_STATUS.COMMITED;
      currentTransaction.commit();
    }
    return true;
  }

  public void rollbackTransaction() {
    if (openTrasactionCalls < 1) {
      return;
    }
    openTrasactionCalls = 0;
    if (currentTransaction.isActive()
        && transactionStatus != TXN_STATUS.ROLLBACK) {
      transactionStatus = TXN_STATUS.ROLLBACK;
      // could already be rolled back
      currentTransaction.rollback();
    }
  }

{code}

Now suppose a nested transaction throws an exception which results
in the nested pseudo-transaction calling rollbackTransaction(). This causes
rollbackTransaction() to rollback the actual transaction, as well as to set 
openTransactionCalls=0 and transactionStatus = TXN_STATUS.ROLLBACK.
Suppose also that this nested transaction squelches the original exception.
In this case the stack will unwind and the caller will eventually try to commit the
transaction by calling commitTransaction() which will see that currentTransaction.isActive()
returns
FALSE and will throw a RuntimeException. The fix for this problem is
that commitTransaction() needs to first check transactionStatus and return immediately
if transactionStatus==TXN_STATUS.ROLLBACK.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message