[ 
https://issues.apache.org/jira/browse/HIVE-16213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15925388#comment-15925388
 ] 

Vihang Karajgaonkar commented on HIVE-16213:
--------------------------------------------

I looked at the method definition. Did not look into the documentation. My IDE 
tells me that currentTransaction.rollback() method can throw a 
{{JDOUserException}}. Not sure why Java is not throwing a compile time check.

{noformat}
  /**
   * Rolls back the current transaction if it is active
   */
  @Override
  public void rollbackTransaction() {
    if (openTrasactionCalls < 1) {
      debugLog("rolling back transaction: no open transactions: " + 
openTrasactionCalls);
      return;
    }
    debugLog("Rollback transaction, isActive: " + 
currentTransaction.isActive());
    try {
      if (currentTransaction.isActive()
          && transactionStatus != TXN_STATUS.ROLLBACK) {
        currentTransaction.rollback();
      }
    } finally {
      openTrasactionCalls = 0;
      transactionStatus = TXN_STATUS.ROLLBACK;
      // remove all detached objects from the cache, since the transaction is
      // being rolled back they are no longer relevant, and this prevents them
      // from reattaching in future transactions
      pm.evictAll();
    }
  }
{noformat}

> ObjectStore can leak Queries when rolbackTransaction 
> -----------------------------------------------------
>
>                 Key: HIVE-16213
>                 URL: https://issues.apache.org/jira/browse/HIVE-16213
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive
>            Reporter: Alexander Kolbasov
>            Assignee: Vihang Karajgaonkar
>
> In ObjectStore.java there are a few places with the code similar to:
> {code}
>     Query query = null;
>     try {
>       openTransaction();
>       query = pm.newQuery(Something.class);
>       ...
>       commited = commitTransaction();
>     } finally {
>       if (!commited) {
>         rollbackTransaction();
>       }
>       if (query != null) {
>         query.closeAll();
>       }
>     }
> {code}
> The problem is that rollbackTransaction() may throw an exception in which 
> case query.closeAll() wouldn't be executed. 
> The fix would be to wrap rollbackTransaction in its own try-catch block.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to