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] Updated: (HIVE-1681) ObjectStore.commitTransaction() does not properly handle transactions that have already been rolled back
Date Wed, 13 Oct 2010 21:30:34 GMT

     [ https://issues.apache.org/jira/browse/HIVE-1681?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Carl Steinbach updated HIVE-1681:
---------------------------------

    Fix Version/s: 0.7.0

> 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
>             Fix For: 0.7.0
>
>         Attachments: HIVE-1681-backport06.1.patch.txt, HIVE-1681.1.patch.txt
>
>
> 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