Alexander Kolbasov created SENTRY-1491:
------------------------------------------

             Summary: 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


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)

Reply via email to