Issue Details (XML | Word | Printable)

Key: CACHE-236
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Andres March
Reporter: Yifeng Chen
Votes: 0
Watchers: 1
Operations

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

removeEntry is unable to delete disk cached file if cache is in full capacity and cache.persistence.overflow.only = true

Created: 17/Feb/06 08:02 AM   Updated: 23/Jul/08 04:09 PM
Component/s: Base Classes
Affects Version/s: 2.1, 2.1.1, 2.2 RC, 2.2 final
Fix Version/s: None

Environment: Win2K server, JRE 1.4.2_08


 Description  « Hide
removeEntry() mehod is unable to delete disk cached file if cache is in full capacity and cache.persistence.overflow.only = true

The problem is from the following code in AbstractConcurrentReadCache, line 1734:

if (overflowPersistence && ((size() + 1) >= maxEntries)) {
persistStore(key, oldValue);


The problem in the code is that if your cache is reached the capacity, more items will overflow to disk, which is correct, but as long as the cache is in this full capacity state, you could never delete the file with flushEnty/removeEntry methods, the file is actually deleted and then re-created due to the above two lines of code.

This behavior is the same in version 2.1 and version 2.2.

Here is the properties of cache in the test:

cache.capacity=4
cache.unlimited.disk=true
cache.persistence.overflow.only=true
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.Ha shDiskPersistenceListener
cache.path=C:\\temp
cache.blocking=true
cache.memory=true

In the test, create 6 cache entires, loop them one by one, so that all 6 will saved to disk.
Then for a specific entry (say entry 2) call method flushEntry then removeEntry, the file is not deleted.

The following patch could fix this particular problem, but may need to test against other cases:
if (overflowPersistence && ((size() + 1) >= maxEntries)
&&
!((CacheEntry)oldValue).needsRefresh(CacheEntry.INDEFINITE_EXPIRY))
{
persistStore(key, oldValue);
}




 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Lars Torunski made changes - 18/Feb/06 06:31 AM
Field Original Value New Value
Assignee Andres March [ dres1011 ]