8 Replies Latest reply on Dec 6, 2007 10:17 AM by arjan

    FileCacheLoader not evicting?

    arjan

      Hi all,

      I've my TreeCache service running (nice to have one appserver wide cache), but I experience some trouble with the FileCacheLoader.

      I cache generated charts and would like to cache them on disc, instead of keeping them in memory. The simplest option would be to create a file-system cache.

      I have a set of regions declared like this:

       <!-- Name of the eviction policy class. -->
       <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</at
      tribute>
      
       <!-- Specific eviction policy configurations. This is LRU -->
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">60</attribute>
      
       <!-- Cache wide default -->
       <region name="/_default_">
       <attribute name="maxNodes">500</attribute>
       <attribute name="timeToLiveSeconds">90</attribute>
       <!-- Maximum time an object is kept in cache regardless of idle time -->
       <attribute name="maxAgeSeconds">90</attribute>
       </region>
      
       <region name="/nl/yirdis/charts/day">
       <attribute name="maxNodes">100</attribute>
       <attribute name="timeToLiveSeconds">60</attribute>
       <attribute name="maxAgeSeconds">60</attribute>
       </region>
      
       <region name="/nl/yirdis/charts/week">
       <attribute name="maxNodes">100</attribute>
       <attribute name="timeToLiveSeconds">7200</attribute>
       <attribute name="maxAgeSeconds">7200</attribute>
       </region>
      
       <region name="/nl/yirdis/charts">
       <attribute name="maxNodes">1000</attribute>
       <attribute name="timeToLiveSeconds">86400</attribute>
       <attribute name="maxAgeSeconds">86400</attribute>
       </region>
      
       </config>
       </attribute>
      


      And a cache-loader configuration:

       <attribute name="CacheLoaderConfiguration">
       <config>
       <passivation>false</passivation>
       <preload></preload>
       <shared>false</shared>
      
       <cacheloader>
       <class>org.jboss.cache.loader.FileCacheLoader</class>
       <properties>
       location=/data2/jboss/cache
       </properties>
       <async>false</async>
       <fetchPersistentState>true</fetchPersistentState>
       <ignoreModifications>false</ignoreModifications>
       </cacheloader>
       </config>
       </attribute>
      


      I can see the entities are stored on the filesystem, only they are not evicted. The eviction interceptor and friends recognise old entries and remove them (according to the log). However, the next time the chart is requested I get the old should-have-been-removed chart.

      Piece of (trace) logging:

      [LRUAlgorithm] Node /nl/yirdis/charts/day/sensor#31/800x500 has been idle for 60001ms
      [LRUAlgorithm] Node /nl/yirdis/charts/day/sensor#31/800x500 should be evicted because of idle time
      [BaseEvictionAlgorithm] Attempting to evict cache node with fqn of /nl/yirdis/charts/day/sensor#31/800x500
      [TxInterceptor] (null) call on method [_evict; id:8(/nl/yirdis/charts/day/sensor#31/800x500)]
      [CacheLoaderInterceptor] invoke _evict; id:8(/nl/yirdis/charts/day/sensor#31/800x500)
      [CacheStoreInterceptor] CacheStoreInterceptor called with meth _evict; id:8(/nl/yirdis/charts/day/sensor#31/800x500)
      [PessimisticLockInterceptor] PessimisticLockInterceptor invoked for method _evict; id:8(/nl/yirdis/charts/day/sensor#31/800x500)
      [PessimisticLockInterceptor] Attempting to lock node /nl/yirdis/charts/day/sensor#31/800x500 for owner Thread[Timer-8,5,jboss]
      [Node] acquiring RL: fqn=/, caller=Thread[Timer-8,5,jboss], lock=<unlocked>
      [...]
      [CallInterceptor] Invoking method _evict; id:8(/nl/yirdis/charts/day/sensor#31/800x500) on cache.
      [TreeCache] _evict(/nl/yirdis/charts/day/sensor#31/800x500)
      [TreeCache] _remove(null, "/nl/yirdis/charts/day/sensor#31/800x500")
      [AbstractNode] removed child 800x500
      [EvictionInterceptor] Invoking EvictionInterceptor
      [EvictionInterceptor] Updating node/element events with no tx
      [EvictionInterceptor] No node modifications
      [EvictionInterceptor] Finished invoking EvictionInterceptor
      [UnlockInterceptor] Attempting to release locks on current thread. Lock table is {Thread[Timer-8,5,jboss]=[read owners=[Thread[Timer-8,5, jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]], read owners=[Thread[Timer-8,5,jboss]]]}
      [UnlockInterceptor] releasing lock for /nl/yirdis/charts/day/sensor#31/800x500: read owners=[Thread[Timer-8,5,jboss]]
      


      What did I miss?

      Thanks,

      Arjan

        • 1. Re: FileCacheLoader not evicting?
          arjan

          .. and when I disable the FileCacheLoader, everything works as expected...

          • 2. Re: FileCacheLoader not evicting?
            haribaasha

            u have a inmemory cache and filesystem store. wat ur eviction policy will do is evict from inmemory based on either timetolive or maxage and tat will push it to filesystem. when u load after eviction has happened it will be reloaded to the inmemory cache from filecache. this is wat must be happening, the problem ?

            • 3. Re: FileCacheLoader not evicting?
              arjan

              Okay, well I didn't expect it to work that way :( .

              Well, I expected the cached data to be timed out. So it is discarded from the cache all together (file and memory).

              How do I make that work then? The data should be evicted from the FileCache after some time, since I work with charts that are only valid for a specific period of time.

              • 4. Re: FileCacheLoader not evicting?
                devimohanty

                i am also facing the same problem .Can any body guide us .

                • 5. Re: FileCacheLoader not evicting?
                  manik

                   

                  "arjan" wrote:
                  Okay, well I didn't expect it to work that way :( .


                  You should have read the manual then. :-) That is precisely how it is designed to work.

                  The cache is an in-memory one which can be backed up onto disk using a CacheLoader. Eviction removes stuff from memory to free up memory and prevent OOMs. But it will not remove stuff from disk so state is not lost.

                  What you want is EXPIRATION, not eviction. We don't support expiry from disk at the moment, but if you want all you need is to add a timestamp to the attribute of each node in the cache, and have a separate thread run periodically, walk the tree and inspect the timestamps of each node, and do a cache.remove() on expired nodes.

                  • 6. Re: FileCacheLoader not evicting?
                    arjan

                    Okay, thanks. I think I can do that.

                    I think the definition of eviction vs expiration got me then.

                    I already have some cache.remove() stuff in place to invalidate cache entries when the underlaying data objects are changed.
                    I only have to add more of that :)).

                    The tricky point is that when data is evicted from the cache and no cache loader is present, the data is lost. While with cache loader the data is persisted and is *not* lost at all.

                    I can't make that up from the documentation, though. The docs are stating that when an element is not in the in-memory cache it's fetched from the cache loader. If nodes are modified they're persisted to the backend store (see chapter 7, JBossCache 1.4.1).


                    Regards,

                    Arjan

                    • 7. Re: FileCacheLoader not evicting?
                      manik

                      Yeah, the 1.x docs may not be as clear as they could. Have you looked at the 2.x docs? Sure, some features may not apply but the docs have been completely reorganised and to a large part rewritten.

                      • 8. Re: FileCacheLoader not evicting?
                        arjan

                        Nope, haven;t checked those as I'm using the 1.* version ;). That's what the JBoss AS distro is using. I'll have a look the next time I run unto trouble ;).