Issue Details (XML | Word | Printable)

Key: NUCCACHE-16
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Fernando Padilla
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Cache

Level2 cache evicts all cache objects at close but need option to leave when sharing in a cluster

Created: 26/Jul/10 12:08 AM   Updated: 16/Oct/10 01:15 PM   Resolved: 25/Sep/10 11:51 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.2


 Description  « Hide
Looking over the code, it looks that the method Level2Cache.clear() is called when a particular PersistenceManagerFactory is about to be shutdown (like turning off one node out of the cluster). But it looks as if the EhcacheLevel2Cache.clear() method calls removeAll() which in turns removes all cached objects throughout the ehcache cluster. It should be calling: removeAll(true), to remove all objects in the local cache, but leave the caches in other nodes intact, since they are still doing work.

So I think this is what it should be (in pseudo code):


function clear() { cache.removeAll( true ); }

function evictAll() { cache.removeAll( false ); }



Andy Jefferson added a comment - 22/Sep/10 09:24 AM
And that method doesn't exist in earlier versions of EHCache, hence would restrict access for the ehcache plugin to specific versions

Andy Jefferson made changes - 22/Sep/10 09:24 AM
Field Original Value New Value
Issue Type Bug [ 1 ] Improvement [ 4 ]
Component/s EHCache [ 10190 ]
Fernando Padilla added a comment - 22/Sep/10 10:19 PM
so, it shouldn't call removeAll() at all then! :)

It's really a HUGE issue here. To wipe our your whole cluster's L2 cache across all machines, when you're just restarting a single node.

plus, aren't all your plugins versioned? We're just saying that the latest version of the datanucleus-cache requires the latest version of ehcache, to fix a huge performance issue. That's an ok statement to make.

Andy Jefferson added a comment - 23/Sep/10 08:17 AM
Of course "clear" should remove all objects; that's what it is for. The user calls clear and it removes them.

If instead you are referring to *having an option* of not clearing the data from the external caching product when the L2 cache itself is closed then fine .... but that is not what you wrote above. The L2 cache is closed when the PMF (or EMF) is closed and the L2 cache is only designed for one PMF (or EMF) actually. For this option you could easily contribute a patch defining a persistence property and making use of it in the constructor of the EHCache plugin class (in the same way as other persistence properties are made use of).

Fernando Padilla added a comment - 24/Sep/10 01:16 AM
ah. ok. I'll take that compromise. :)

As the PMF is being shutdown, it should not proactively clear/evictAll from the cache. (or at least make it configurable).

Ok, I'll try to suggest a patch for this, unless you have something in mind. (I assume it should be just commenting out one line of code).

Andy Jefferson made changes - 25/Sep/10 11:50 AM
Summary EhcacheLevel2Cache evicts all cache objects through out cluster inappropriately Level2 cache evicts all cache objects at close but need option to leave when sharing in a cluster
Component/s EHCache [ 10190 ]
Andy Jefferson added a comment - 25/Sep/10 11:51 AM
"datanucleus.cache.level2.clearAtClose" allows a user to override specification JDO/JPA behaviour of removing objects from L2 cache at close

Andy Jefferson made changes - 25/Sep/10 11:51 AM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 2.1.2 [ 11040 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 16/Oct/10 01:15 PM
Status Resolved [ 5 ] Closed [ 6 ]