[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Persistent cache not reloading on restart  XML
Forum Index -> Ehcache
Author Message
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

I am currently working on a Grails plugin to create a disk persistent cache using EhCache. I have everything working except reloading the cache on restart. I can see that as I use my app, values are being cached correctly. I can see the cache's .data and .index files are created (and neither are empty). However, when the app is restarted, both files are cleared out and the cache is not reloaded. I do have the ShutdownListener configured in my web.xml. Any help anyone can provide is appreciated!

ehcache.xml
Code:
 <?xml version="1.0" encoding="UTF-8"?>
 <ehcache>
 
     <!-- I am using this directory only for development -->
     <diskStore path="/tmp"/>
 
 
     <defaultCache maxElementsInMemory="1000" 
                   eternal="false" 
                   timeToIdleSeconds="120" 
                   timeToLiveSeconds="120" 
                   overflowToDisk="false"/>
 
     <cache name="grails.plugin.persistent_cache.default"
 		maxElementsInMemory="500" 
                 eternal="true"
                 overflowToDisk="true" 
                 timeToIdleSeconds="300" 
                 timeToLiveSeconds="600"
                 diskPersistent="true" 
                 diskExpiryThreadIntervalSeconds="1"
                 memoryStoreEvictionPolicy="LFU" />
 </ehcache>
 
[WWW]
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1491
Offline

Hi,

I tried reproducing the scenario using your ehcache configuration , but it's working fine for me . Are you doing proper shutdown of Cachemanager.

Rakesh Joshi
Senior Consultant
Terracotta.
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

With regards to a proper shutdown of Cachemanager, I have the ShutdownListener configured in my web.xml as a listener and can see that the .index file is being written out. What else can I do to validate that the Cachemanager is being shutdown correctly?
[WWW]
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

I hate to be a pain but I wanted to bump this topic. Are there any recommended approaches to debugging this issue?
[WWW]
ari

seraphim

Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline

Is this persistent to Terracotta array or to local disk. if local disk, the disk repo could have been flagged dirty and is not being trusted. Post up your full logs on restart for us to see if this is the case.

if this is to an array, then how much data is in the array and is it all expired?

If on local disk, try switching to an array just for a minute to isolate the problem to your config or ours. If you can restart and reconnect to the array and get your data back, then we will want to look at ehcache.xml. if not, we will want to look at your grails app further.

--Ari
[WWW]
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

Thanks for the reply!

I'm persisting to a local disk (per the ehcach.xml configuration in the first post of this thread) and have the elements configured as eternal so no risk of expiration. My logs on restart are not showing anything of use (that I can see). Is there something I can turn on with regards to logging to get more information?

Michael
[WWW]
ari

seraphim

Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline

http://ehcache.org/documentation/operations/logging

Wanna try to set DEBUG logging and see if that gets us a notification that the disk store is corrupt and not being trusted? That will be faster than trying an array.

--Ari
[WWW]
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

Below is the log from my most recent startup. It looks like it doesn't like that it's auto creating the directory it's storing the data in. How do I correct my configuration so that this isn't an issue?

Code:
 
 | Loading Grails 2.0.1
 | Configuring classpath.
 | Environment set to development.....
 | Packaging Grails application.....
 | Downloading: plugins-list.xml.....
 | Downloading: plugins-list.xml.....
 | Running Grails application
 Configuring Spring Security Core ...
 ... finished configuring Spring Security Core
 15:49:47 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from ehcache.xml found in the classpath: file:/Users/someuser/.grails/2.0.1/projects/someapplication/resources/ehcache.xml
 15:49:47 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from URL: file:/Users/someuser/.grails/2.0.1/projects/someapplication/resources/ehcache.xml
 15:49:47 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from InputStream
 15:49:47 | [DEBUG] | config.DiskStoreConfiguration | Disk Store Path: /tmp
 15:49:47 | [DEBUG] | util.PropertyUtil | propertiesString is null.
 15:49:47 | [DEBUG] | config.ConfigurationHelper | No CacheManagerEventListenerFactory class specified. Skipping...
 15:49:47 | [DEBUG] | ehcache.Cache | No BootstrapCacheLoaderFactory class specified. Skipping...
 15:49:47 | [DEBUG] | ehcache.Cache | CacheWriter factory not configured. Skipping...
 15:49:47 | [DEBUG] | config.ConfigurationHelper | No CacheExceptionHandlerFactory class specified. Skipping...
 15:49:47 | [DEBUG] | ehcache.Cache | No BootstrapCacheLoaderFactory class specified. Skipping...
 15:49:47 | [DEBUG] | ehcache.Cache | CacheWriter factory not configured. Skipping...
 15:49:47 | [DEBUG] | config.ConfigurationHelper | No CacheExceptionHandlerFactory class specified. Skipping...
 15:49:47 | [DEBUG] | factories.DiskPersistentStorageFactory | Matching data file missing (or empty) for index file. Deleting index file /tmp/grails.plugin.persistent_cache.default.index
 15:49:47 | [DEBUG] | ehcache.Cache | Initialised cache: grails.plugin.persistent_cache.default
 15:49:47 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured. Skipping for 'grails.plugin.persistent_cache.default'.
 15:49:47 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured for defaultCache. Skipping for 'grails.plugin.persistent_cache.default'.
 15:49:47 | [DEBUG] | ehcache.Cache | Initialised cache: com.ncv.nfv.Role
 15:49:47 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured for defaultCache. Skipping for 'com.ncv.nfv.Role'.
 15:49:48 | [DEBUG] | ehcache.Cache | Initialised cache: org.hibernate.cache.UpdateTimestampsCache
 15:49:48 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured for defaultCache. Skipping for 'org.hibernate.cache.UpdateTimestampsCache'.
 15:49:48 | [DEBUG] | ehcache.Cache | Initialised cache: org.hibernate.cache.StandardQueryCache
 15:49:48 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured for defaultCache. Skipping for 'org.hibernate.cache.StandardQueryCache'.
 15:49:48 | [DEBUG] | ehcache.CacheManager | Configuring ehcache from classpath.
 15:49:48 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from ehcache.xml found in the classpath: file:/Users/someuser/.grails/2.0.1/projects/someapplication/resources/ehcache.xml
 15:49:48 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from URL: file:/Users/someuser/.grails/2.0.1/projects/someapplication/resources/ehcache.xml
 15:49:48 | [DEBUG] | config.ConfigurationFactory | Configuring ehcache from InputStream
 15:49:48 | [DEBUG] | config.DiskStoreConfiguration | Disk Store Path: /tmp
 15:49:48 | [DEBUG] | util.PropertyUtil | propertiesString is null.
 15:49:48 | [WARN ] | ehcache.CacheManager | Creating a new instance of CacheManager using the diskStorePath "/tmp" which is already used by an existing CacheManager.
 The source of the configuration was net.sf.ehcache.config.generator.ConfigurationSource$DefaultConfigurationSource@63e5a3e.
 The diskStore path for this CacheManager will be set to /tmp/ehcache_auto_created_1330984188464.
 To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
 15:49:48 | [DEBUG] | config.ConfigurationHelper | No CacheManagerEventListenerFactory class specified. Skipping...
 15:49:48 | [DEBUG] | ehcache.Cache | No BootstrapCacheLoaderFactory class specified. Skipping...
 15:49:48 | [DEBUG] | ehcache.Cache | CacheWriter factory not configured. Skipping...
 15:49:48 | [DEBUG] | config.ConfigurationHelper | No CacheExceptionHandlerFactory class specified. Skipping...
 15:49:48 | [DEBUG] | ehcache.Cache | No BootstrapCacheLoaderFactory class specified. Skipping...
 15:49:48 | [DEBUG] | ehcache.Cache | CacheWriter factory not configured. Skipping...
 15:49:48 | [DEBUG] | config.ConfigurationHelper | No CacheExceptionHandlerFactory class specified. Skipping...
 15:49:48 | [WARN ] | factories.DiskPersistentStorageFactory | Data in persistent disk stores is ignored for stores from automatically created directories (they start with ehcache_auto_created).
 Remove diskPersistent or resolve the conflicting disk paths in cache configuration.
 Deleting data file /tmp/ehcache_auto_created_1330984188464/grails.plugin.persistent_cache.default.data
 15:49:48 | [DEBUG] | factories.DiskPersistentStorageFactory | Matching data file missing (or empty) for index file. Deleting index file /tmp/ehcache_auto_created_1330984188464/grails.plugin.persistent_cache.default.index
 15:49:48 | [DEBUG] | ehcache.Cache | Initialised cache: grails.plugin.persistent_cache.default
 15:49:48 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured. Skipping for 'grails.plugin.persistent_cache.default'.
 15:49:48 | [DEBUG] | config.ConfigurationHelper | CacheDecoratorFactory not configured for defaultCache. Skipping for 'grails.plugin.persistent_cache.default'.
 
[WWW]
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

It looks like this issue is something others have had:
http://forums.terracotta.org/forums/posts/list/6440.page

Does anyone have any insight into how to fix this issue?
[WWW]
klalithr

consul

Joined: 01/23/2011 10:58:07
Messages: 489
Offline

What version of Ehcache are you using? With the same version, can you write a simple standalone program and verify the behavior

Karthik Lalithraj (Terracotta)
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

I'm using ehcache 2.4.6. I'm not sure what you mean by write a small program to verify the behavior. My application is demonstrating the behavior I've described using the configuration posted. Am I missing something?
[WWW]
mminella

journeyman

Joined: 02/20/2012 10:38:20
Messages: 10
Location: Illinois
Offline

So I figured out this issue. The logs are not quite complete when starting a grails app. When my app starts, a CacheManager is created (not displayed in the log file) for hibernate second level caching. My app was also creating a CacheManager as well. Because two cache managers were being created using the same configuration I ended up with two cache managers both pointing to the same directory...hence the issue.

To fix the issue, I had to update the hibernate configuration in my DataSource.groovy file to use net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory as the factory class instead of net.sf.ehcache.hibernate.EhCacheRegionFactory.

While I'm now running into an issue where the startup can't find the class I'm using as my cache key, at least it is now trying to read it in the first place.
[WWW]
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team