• Bug
  • Status: Open
  • 3 Minor
  • Resolution:
  • ehcache-core
  • dwithers
  • Reporter: dwithers
  • July 12, 2012
  • 0
  • Watchers: 6
  • April 10, 2013

Attachments

Description

We are using several singleton caches to hold various objects, and we’re using disk overflow caching as well. What we see is that sometimes, the code can get an element from the cache, and then immediately find that getKeys() returns an incomplete list. That is, it doesn’t contain the key we just used to find the element. Expired or evicted, you say? No…cache.isKeyInCache() returns true after the call to getKeys(). If we disable disk overflow caching, this problem goes away.

Attached is a segment of the log with ehcache logging dialed up. It basically shows where we have a cache hit, and read an element from the cache. Immediately following that, getKeys() returns a list not containing our key.

Here is our cache.xml file (partial):

Code:

Our intention is to never let objects expire from the memory store (ie, eternal), but rather to have them overflow to disk (ie, overflowToDisk=true). The disk cache should not survive a restart (ie, diskPersistent=false). We control the number of elements in the memory store via maxElementsInMemory, and do some manual eviction (via delete). As I mentioned above, if I disable disk overflow caching, this problem goes away. By disable disk caching, I have to: - configure a TTI value (I used 60) - configure a TTL value (I used 120) - configure eternal="false" - configure overflowToDisk="false" </div> ## Comments {:.comment-heading} ### **Fiona OShea** 2012-07-16

Can you take a quick look and give your opinion?

{:.comment-heading} ### **Chris Dennis** 2012-09-06

David,

This certainly looks strange, I can’t see or think of anything that could be causing this off the top of my head, and I’ve spent some time reviewing the code around this area and can’t see anything obviously suspicious. If you are able to provide us with a reproducible test case then that would be great. If that’s not possible or practical then a detailed description of what your application does to the cache would be the next best thing. The sort of detail I’m thinking of is:

  1. How many threads access the cache concurrently.
  2. What operations are the various threads performing.
  3. Are you doing anything out of the ordinary like mutating the configuration at runtime?

Thanks,

Chris