<< Back to previous view

[OSCACHE-4] Concurrent issue for LRU, cache size exceed default max cachesize Created: 15/Feb/12  Updated: 15/Feb/12

Status: Open
Project: oscache
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: fightf Assignee: Unassigned
Resolution: Unresolved Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

centos+tomcat7


Tags:
Participants: fightf

 Description   

OSCache version is 2.4.1

Precondition:
We use oscache to cache ibatis resultset, default max cache size is "1000" and the cache algorithm is LRU.
We do one performance testing for our application. our app call get/put/flush method to update the resultset.

Except result
The performance keep good.

Actually Result
The performance is bad when run serials times, we debug it and find the cache size growth very quickly, it will growth to 10000, this number is larger than the default max size.

And we analyze the oscache code and find there is one issue in LRU algorithm.
When cache size is full, LRU cache key sequence is "Key1-> Key2->Key3->Key4...KeyN-1"
Thread A want to push one value to the cache with KeyN, it will entry synchronized statement to prepare remove the Key1 and it's value.
at the same time, Thread B use Key1 to get the object from cachemap before , as LRU requirement, we must move key1 to the end of the queue. But actually the key1 already be removed by Thread A.
That will cause LRU key's list size is large than cachemap size.

The error code in LRUCache.java
protected void itemRetrieved(Object key) {
....
synchronized (list) { list.remove(key); list.add(key); }
}
My solution is "add one protection"
protected void itemRetrieved(Object key) {
....
synchronized (list) {
if(list. contains(key)){ list.remove(key); list.add(key); }
}
}






[OSCACHE-3] Upload 2.4.1 to maven2 central repository Created: 19/Sep/08  Updated: 19/Sep/08

Status: Open
Project: oscache
Component/s: www
Affects Version/s: current
Fix Version/s: not determined

Type: Task Priority: Major
Reporter: mattbishop Assignee: oscache-issues
Resolution: Unresolved Votes: 1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 3
Tags:
Participants: mattbishop and oscache-issues

 Description   

The current version in the maven repository is 2.4, but 2.4.1 is the current release of oscache. See http://repo1.maven.org/maven2/opensymphony/oscache/

Please upload the latest version. For instructions, see http://maven.apache.org/guides/mini/guide-
central-repository-upload.html



 Comments   
Comment by mattbishop [ 19/Sep/08 05:49 PM ]

Changing some fields to match conditions.





[OSCACHE-2] Default for cache.path Created: 12/Mar/05  Updated: 16/Mar/05

Status: Open
Project: oscache
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Improvement Priority: Major
Reporter: shishirksingh Assignee: oscache-issues
Resolution: Unresolved Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


File Attachments: Java Source File AbstractDiskPersistenceListener.java    
Issuezilla Id: 2
Tags:
Participants: oscache-issues and shishirksingh

 Description   

If cache.path is not defined, then default the cache to java.io.tmpdir



 Comments   
Comment by shishirksingh [ 16/Mar/05 08:59 PM ]

Created an attachment (id=1)
Patched AbstractDiskPersistenceListener.java file





[OSCACHE-1] OSCache caching response from GZIP filter Created: 27/Oct/04  Updated: 27/Oct/04

Status: Open
Project: oscache
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Bug Priority: Major
Reporter: bendg25 Assignee: chris_miller
Resolution: Unresolved Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Issuezilla Id: 1
Tags:
Participants: bendg25 and chris_miller

 Description   

Hi

I am working with Matt Raibles Appfuse GZIP Filter and wanted the OSCache to
cache the GZIP response from that filter (as I want a smaler memory footprint
and I dont want to GZIP all the time...)....

But when I OS Cached the GZIP response, the next time it returned the response
it was gibberish....

I took the latest OSCache from CVS and added setContentEncoding("gzip").. on the
response inside ReponseContent and it then worked...

Is this a bug??

Full trace of what I did:

OSCache 2.0.2 did not work either ...

I tried the latest from the CVS and it works as there is new logic in the
CacheFilter stating:

[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(63) | GOT KEY OF
[/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==]
[oof] DEBUG [http-8080-Processor23] AbstractConcurrentReadCache.get(696) | get
called (key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)
[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(70) | respContent
content type is [text/html;charset=utf-8]
[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(71) | respContent locale
is [US]
[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(73) | <cache>: Using
cached entry for /oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==
[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(77) | clientLastModified
is [-1]
[oof] INFO [http-8080-Processor23] CacheFilter.doFilter(80) | SENDING BACK A
SC_NOT_MODIFIED

BUT WITH THE SC_NOT_MODIFIED commented out I get the same error...

NOTE: The same gibberish is seen on a Mozilla browser and a IE browser...

I think it could be todo with the way it stores the content type?

TRACE ADDING

[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(95) | calling
flushBuffer on cacheResponse
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(101) | STATUS IS 200
SC_OK SO CACHING THE CONTENT with key
[/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(104) | caching response
content with content type [text/html;charset=utf-8]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(105) | size is [2318]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(106) | country locale is
[US]
[oof] DEBUG [http-8080-Processor25] AbstractConcurrentReadCache.get(696) | get
called (key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)
[oof] DEBUG [http-8080-Processor25]
AbstractConcurrentReadCache.persistRetrieve(1039) | persistRetrieve called
(key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)
[oof] DEBUG [http-8080-Processor25] Cache.getCacheEntry(611) | No cache entry
exists for key='/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==', creating
[oof] DEBUG [http-8080-Processor25]
AbstractConcurrentReadCache.persistStore(1086) | persistStore called
(key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)

AND WHEN RETRIEVING

[oof] DEBUG [http-8080-Processor24] AuthenticatorBase.invoke(413) | Security
checking request GET /oof/todaysRaces.html
[oof] DEBUG [http-8080-Processor24] AuthenticatorBase.invoke(428) | We have
cached auth type FORM for principal GenericPrincipal[mraible(admin,)]
[oof] DEBUG [http-8080-Processor24] AuthenticatorBase.invoke(484) | Calling
hasUserDataPermission()
[oof] DEBUG [http-8080-Processor24] AuthenticatorBase.invoke(520) | Calling
accessControl()
[oof] DEBUG [http-8080-Processor24] AuthenticatorBase.invoke(538) |
Successfully passed all security constraints
[oof] DEBUG [http-8080-Processor24] StandardWrapper.allocate(700) | Returning
non-STM instance
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(59) | <cache>: filter in
scope 4
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(63) | GOT KEY OF
[/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==]
[oof] DEBUG [http-8080-Processor24] AbstractConcurrentReadCache.get(696) | get
called (key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(70) | respContent
content type is [text/html;charset=utf-8]
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(71) | respContent locale
is [US]
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(73) | <cache>: Using
cached entry for /oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(77) | clientLastModified
is [-1]
[oof] INFO [http-8080-Processor24] CacheFilter.doFilter(84) | SENDING BACK
RESPONSE SIZE IS [2318]

ADDED THIS:

response.setContentLength(compressedBytes.length);
log.debug("setting Content-Encoding to gzip");
response.addHeader("Content-Encoding", "gzip");

AND IT WORKS:

oof] DEBUG [http-8080-Processor25] AuthenticatorBase.invoke(538) | Successfully
passed all security constraints
[oof] DEBUG [http-8080-Processor25] StandardWrapper.allocate(700) | Returning
non-STM instance
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(59) | <cache>: filter in
scope 4
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(63) | GOT KEY OF
[/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==]
[oof] DEBUG [http-8080-Processor25] AbstractConcurrentReadCache.get(696) | get
called (key=/oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==)
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(70) | respContent
content type is [text/html;charset=utf-8]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(71) | respContent locale
is [US]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(73) | <cache>: Using
cached entry for /oof/todaysRaces.html_GET__DKDmrGxVhXXmMDcqxOikoQ==
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(77) | clientLastModified
is [-1000]
[oof] INFO [http-8080-Processor25] CacheFilter.doFilter(84) | SENDING BACK
RESPONSE SIZE IS [2318]
[oof] DEBUG [http-8080-Processor25] ResponseContent.writeTo(114) | SETTING
HEADER CONTENT ENCODING TO GZIP






Generated at Sat Apr 19 02:13:35 UTC 2014 using JIRA 4.0.2#472.