10 Replies Latest reply on Feb 4, 2016 4:52 PM by Radoslav Husar

    Wildfly 10 support for optimistic web cache

    Mathieu Lachance Novice

      Hello everyone,

       

      I'm currently trying to setup the distributed web session cache to be optimistic in Wildfly 10.0.0.CR5 as following:

      {code}

                  <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">

                      <transport lock-timeout="60000"/>

                      <distributed-cache name="dist" mode="ASYNC" l1-lifespan="0" owners="2">

                          <locking locking="OPTIMISTIC" isolation="READ_COMMITTED"/>

                          <transaction mode="BATCH"/>

                      </distributed-cache>

                  </cache-container>

      {code}


      But each time, I'm getting "Explicit locking is not allowed with optimistic caches!" :

      {code}

      Caused by: org.infinispan.InvalidCacheUsageException: Explicit locking is not allowed with optimistic caches!

                at org.infinispan.interceptors.locking.OptimisticLockingInterceptor.visitLockControlCommand(OptimisticLockingInterceptor.java:142) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.TxInterceptor.invokeNextInterceptorAndVerifyTransaction(TxInterceptor.java:157) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.TxInterceptor.visitLockControlCommand(TxInterceptor.java:215) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:113) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:163) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.statetransfer.TransactionSynchronizerInterceptor.visitLockControlCommand(TransactionSynchronizerInterceptor.java:78) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.statetransfer.StateTransferInterceptor.handleTxCommand(StateTransferInterceptor.java:238) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.statetransfer.StateTransferInterceptor.visitLockControlCommand(StateTransferInterceptor.java:102) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:107) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.InvocationContextInterceptor.visitLockControlCommand(InvocationContextInterceptor.java:81) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:113) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:163) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:110) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:336) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.cache.impl.CacheImpl.lock(CacheImpl.java:828) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.cache.impl.DecoratedCache.lock(DecoratedCache.java:136) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.infinispan.cache.impl.AbstractDelegatingAdvancedCache.lock(AbstractDelegatingAdvancedCache.java:177) ~[infinispan-core-8.1.0.Final.jar!/:8.1.0.Final]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSessionMetaDataFactory.remove(InfinispanSessionMetaDataFactory.java:124) ~[?:?]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSessionMetaDataFactory.remove(InfinispanSessionMetaDataFactory.java:39) ~[?:?]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.remove(InfinispanSessionFactory.java:89) ~[?:?]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.remove(InfinispanSessionFactory.java:40) ~[?:?]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSession.invalidate(InfinispanSession.java:67) ~[?:?]

                at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager$SchedulableSession.invalidate(InfinispanSessionManager.java:439) ~[?:?]

                at org.wildfly.clustering.web.undertow.session.DistributableSession.invalidate(DistributableSession.java:181) ~[?:?]

                at io.undertow.servlet.spec.HttpSessionImpl.invalidate(HttpSessionImpl.java:199) ~[undertow-servlet-1.3.12.Final.jar!/:1.3.12.Final]

      ...

      {code}


      That said, this configuration was working fine in either EAP 6.1 and Wildfly 8.2.1.Final with [WFLY-5331] ConcurrentModificationException in InfinispanSessionManager.findListeners - JBoss Issue Tracker backported.

       

      I know there was some debates wheter if optimistic session cache should be a thing or not according to the specs:

      HTTP Session Replication - org.infinispan.util.concurrent.TimeoutException

      Servlet 3.0 final specification under section 7.7.1 and 7.7.2

       

      Sadly, the application I'm currently trying to migrate to Wildfly 10.0.0.CR5+ is dependent of that optimistic behavior and I was wondering if that clustering configuration was still supported or not?

      If it should, then I'll raise a ticket.

      Else, if this is by design, is there any best pattern to follow when dealing with pessimistic web session cache? Would moving attribute to @SessionScoped bean would help, or under the hood, SessionScoped bean implementation just piggyback on the session attributes?

       

      Thanks,