You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sentry.apache.org by "Alexander Kolbasov (JIRA)" <ji...@apache.org> on 2016/11/03 07:56:58 UTC

[jira] [Resolved] (SENTRY-1491) Sentry transactions are not rolled back immediately when commit fails

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

Alexander Kolbasov resolved SENTRY-1491.
----------------------------------------
    Resolution: Fixed

This is fixed by SENTRY-1422

> Sentry transactions are not rolled back immediately when commit fails
> ---------------------------------------------------------------------
>
>                 Key: SENTRY-1491
>                 URL: https://issues.apache.org/jira/browse/SENTRY-1491
>             Project: Sentry
>          Issue Type: Bug
>          Components: Sentry
>    Affects Versions: 1.7.0, sentry-ha-redesign
>            Reporter: Alexander Kolbasov
>            Assignee: Alexander Kolbasov
>
> Here is the code for commitTransaction:
> {code}
> public void commitTransaction(PersistenceManager pm) {
>   Transaction currentTransaction = pm.currentTransaction();
>   try {
>     Preconditions.checkState(currentTransaction.isActive(), "Transaction is not active");
>     currentTransaction.commit();
>   } finally {
>     pm.close();
>   }
> }
> {code}
> so it does pm.close() in the finally clause, so it always closes pm. 
> Now everyone else does something like
> {code}
>   commitTransaction(pm);
>   rollbackTransaction = false;
>   return roles;
> } finally {
>   if (rollbackTransaction) {
>     rollbackTransaction(pm);
>   }
> }
> {code}
> which means that pm is closed by the time we call rollbackTransaction() and we never rollback when commit fails. As a result rollback is deferred till connection close (which may be some time due to connection pooling) and we are potentially holding various locks for longer than needed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)