1 Reply Latest reply on Nov 17, 2006 12:07 PM by manik

    INVALIDATION Cache problem

    amits2

      I am working on an application with Spring, hibernate and JBoss Tree cache. This application is deployed on a WEBLOGIC cluster environment. I am using tree cache to store only the SELECTED domain objects in tree cache with mode INVALIDATION_ASYNC (i also tried INVALIDATION_SYNC).

      What I understood from the INVALIDATION cache is "Whenever data is changed in a cache, ohter caches in a cluster receive an invalidation message, which means their data is now state and should be evicted from cache".

      This is what I am doing and I noticed while using Tree cache Invalidation_async cache:

      1. I am using an interceptor (Hibernate Interceptor) to check the object to be cached. If that element is already exist in tree cache then cache object will be returned, otherwise it will continue with the normal process (step 2).

      2. Here, hibernate calls goes to database and return the domain object, which are programatically put in the tree cache for later use and when a request comes for that particular object, STEP 1 is being executed.

      3. My application can receive updates for the domain objects, when this updates comes, [B] I update the cache with updated object and save the new value to database.

      The above steps works fine in cluster environment for REPLICATION mode and I can see the object are replicated on each and every nodes.

      But when I change cache mode to "INVALIDATION_ASYNC" the problem starts:

      Here is my usecase:

      1. I send a request goes to node 1 of a weblogic cluster, this is what happens:
      Domain object (lets say domain1) are created and put in to cache.

      2. I send the same request to node 2 of weblogic cluster, this is what happens:
      Domain objects [same as in request 1, domain1] are created and put in cache on node 2.

      3. Then I receive an update on node 1 for Domain Object [domain1]:
      Here, I put that updated domain object to cache. Now I assume it will send an invalidation message to node 2 and domain object (domain1)is eviceted from the cache on node2.

      4. Now I Send the same request to node 2 of weblogic cluster (where domain1 is evicted from cache due to invalidation message from node 1's cache):
      Here, I notice that cache item is not available and request is going to the database, construct the object and again put in to cache at node 2 ----------------> Absolutely RIGHT

      5. Now Send the same request to node 1 of weblogic cluster (where cache item domain1 is updated]:

      What I am seeing : "Cache item domain1 doesn't exist here and call is going to the database". ----------> WRONG


      This might be possible that node 2 has sent an invalidation message when it has put the domain1 object in its cache and it invalidates the cache item on node 1 [for domain1] and again the call for same object from node 1 is going to database.

      Am I doing something wrong OR INVALIDATION_ASYNC is not yet supported by Treecache with hibernate????

      Your response will be highly appreciated !!

      Thanks,