[ https://issues.apache.org/jira/browse/SENTRY-1491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15570018#comment-15570018 ]
Alexander Kolbasov edited comment on SENTRY-1491 at 10/12/16 10:08 PM: ----------------------------------------------------------------------- I think that we should close persistance manager using try-with-resources which requires PersistentManager to be closeable. This requires SENTRY-1500. was (Author: akolb): I think that we should close transactions using try-with-resources which requires PersistentManager to be closeable. This requires SENTRY-1500. > 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)