Uploaded image for project: 'Sentry (Retired)'
  1. Sentry (Retired)
  2. SENTRY-1491

Sentry transactions are not rolled back immediately when commit fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.7.0, 2.0.0
    • 1.8.0, 2.0.0
    • Sentry
    • None

    Description

      Here is the code for commitTransaction:

      public void commitTransaction(PersistenceManager pm) {
        Transaction currentTransaction = pm.currentTransaction();
        try {
          Preconditions.checkState(currentTransaction.isActive(), "Transaction is not active");
          currentTransaction.commit();
        } finally {
          pm.close();
        }
      }
      

      so it does pm.close() in the finally clause, so it always closes pm.
      Now everyone else does something like

        commitTransaction(pm);
        rollbackTransaction = false;
        return roles;
      } finally {
        if (rollbackTransaction) {
          rollbackTransaction(pm);
        }
      }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              akolb Alex Kolbasov
              akolb Alex Kolbasov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: