3 Replies Latest reply on Jan 17, 2019 3:27 PM by thammoud

    Hibernate L2 Invalidation Cache and GC

    thammoud

      Hello,

       

      We are testing Infinispan as a L2 Hibernate Cache in SYNC Invalidation mode. Using version 8.2.4 and hibernate version 5.1.17. We start a two node cluster. testbox01 and testbox02. The following is our test:

       

      1. Read Object A from testbox01
      2. Read Object A from testbox02
      3. ctrl-z tesbox02 to simulate a very long GC. Highly unlikely to happen in production but we wanted to test the resiliency.
      4. testbox01 create a new cluster view
      5. Update Object A on testbox01
      6. Re-enable testbox02. New Cluster view containing both nodes is activated
      7. Read Object A from testbox02. Still reads stale version

       

      We would have expected testbox02 to discard all cache entries upon rejoining the cluster and the read in step 7 to go to the database. Any pointers will be appreciated. Thank you.

        • 1. Re: Hibernate L2 Invalidation Cache and GC
          galder.zamarreno

          Good test. I'd suggest you upgrade to latest WildFly version where you can configure Infinispan caches with conflict management and merge policies.

           

          In this case, you'd want that entity caches to be configured with MergePolicy REMOVE_ALL. e.g.

          <invalidation-cache name="entity">

            <transaction mode="NON_XA"/>

            <object-memory size="10000"/>

            <expiration max-idle="100000"/>

            <partition-handling when-split="ALLOW_READ_WRITES" merge-policy="REMOVE_ALL"/>

          </invalidation-cache>

           

          (WildFly 15 comes with Infinispan 9.4.x)

           

          We should have this configured out of the box. ryanemerson ?

          1 of 1 people found this helpful
          • 2. Re: Hibernate L2 Invalidation Cache and GC
            ryanemerson

            thammoud Hi, we actually conducted some very similar tests to yours when developing Infinispan 9.x and unfortunately, we discovered that the scenario that you described was not correctly handled. This has been fixed since 9.2.x, so I suggest that you upgrade to Wildfly 15 like galderz recommends.

             

            Also, please note that it's not possible to define a conflict merge policy with invalidation mode, however the default behaviour is for all entries on the rejoining node to be wiped in ^ scenario.

            1 of 1 people found this helpful
            • 3. Re: Hibernate L2 Invalidation Cache and GC
              thammoud

              Thank you Ryan and Galder. Truly appreciate the help.