Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-26102

Portal cache doesn't rollback correctly in JTA environment

    Details

      Description

      I have been trying to setup Liferay with JTA transactions on JBoss.

      My portal-ext.properties

      # define datasource for liferay
      jdbc.default.jndi.name=java:/jboss/datasources/LiferayPoolXA
      # define separate datasource for Counter
      counter.jdbc.prefix=jdbc.counter.
      jdbc.counter.jndi.name=java:/jboss/datasources/CounterPool
      
      # turn of entity and finder cache, because it causes problems with JtaTransactionManager
      value.object.entity.cache.enabled=false
      value.object.finder.cache.enabled=false
      
      
      # set JtaTransactionManager
      transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager
      transaction.manager.property.allowCustomIsolationLevels=true
      transaction.manager.property.globalRollbackOnParticipationFailure=true
      transaction.manager.property.transactionManagerName=java:jboss/TransactionManager
      transaction.manager.property.userTransactionName=java:jboss/UserTransaction
      
      # Hibernate settins to JTA
      hibernate.current_session_context_class=jta
      hibernate.transaction.manager_lookup_class=eu.ibacz.ibapackage.core.util.JBossAS7TransactionManagerLookup
      

      JBossAS7TransactionManagerLookup is just a simple class needed because of changes in JBoss 7 jndi naming

      public final class JBossAS7TransactionManagerLookup extends JNDITransactionManagerLookup {
       
          @Override
          protected String getName() {
              return "java:jboss/TransactionManager";
          }
       
          @Override
          public String getUserTransactionName() {
              return "java:jboss/UserTransaction";
          }
       
          @Override
          public Object getTransactionIdentifier(Transaction transaction) {
              return transaction;
          }
      }
      

      This works as expected - create something in Liferay, in another database in my application and after rollback both liferay and my application are rolled back correctly, but I had to turn off the portal cache with following settings:

      value.object.entity.cache.enabled=false
      value.object.finder.cache.enabled=false
      

      Without this settings the entry is removed from DB during rollback, but can be still retrieved from portal cache.

      After having done some research I think the problem is with TransactionInterceptor:

      _platformTransactionManager.commit(transactionStatus);
      
      if (transactionStatus.isNewTransaction()) {
          TransactionalPortalCacheHelper.commit();
      
          invokeCallbacks();
      }
      

      In JTA environment successful call of method commit doesn't mean that global transaction will be commited. I guess this has to be implemented using some callback mechanism.

      I was also able to reproduce the same behaviour with Atomikos on tomcat, using similar setup to http://www.liferay.com/community/wiki/-/wiki/Main/JTA-XA+on+Tomcat.

      Let me know if you need more info.

        Attachments

          Activity

            People

            Assignee:
            mika.koivisto Mika Koivisto
            Reporter:
            frant.hartm František Hartman (Inactive)
            Participants of an Issue:
            Recent user:
            Esther Sanz
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              8 years, 15 weeks, 4 days ago

                Packages

                Version Package
                6.1.1 CE GA2