jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amy Wang <amy.w...@intersperse.com>
Subject RE: Errors from LRUMemoryCache
Date Fri, 12 Sep 2003 21:00:46 GMT
The problem is that the update process on MemoryElementDescriptor and the
Map that stores keys should be in one transaction by a thread at any time.
Notice that the update method itself is not synchronized. 

This happens when multiple threads accessing the LRUMemoryCache, not
necessary do they have to access the same ICacheElement. 

for example, in update method, thread-1 finishes addFirst(ce) and releases
hte lock on LRUMemoryCache, but before it calls "old =
(MemoryElementDescriptor)map.put(first.ce.getKey(), first);", some other
threads update the linked list of MemoryElementDescriptor. In this case, the
map and the memory descriptor are out of sync, so the error occurs.
Hope it helps/

> -----Original Message-----
> From: Todd Carmichael [mailto:toddc@concur.com]
> Sent: Wednesday, September 10, 2003 8:58 AM
> To: 'Turbine JCS Developers List'; 'Turbine JCS Users List'
> Subject: RE: Errors from LRUMemoryCache
> 
> 
> Both of the method calls within the synchronized block are 
> already marked as
> synchronized.  How does the synchronized block around the two 
> calls solve a
> problem unless two threads were trying to update the exact 
> same instance of
> ICacheElement?
> 
> ToddC
> 
> 
> -----Original Message-----
> From: Amy Wang [mailto:amy.wang@intersperse.com] 
> Sent: Tuesday, September 09, 2003 7:41 PM
> To: 'Turbine JCS Developers List'; 'Turbine JCS Users List'
> Subject: RE: Errors from LRUMemoryCache
> 
> 
> In case anybody run into the same issue. 
> This problem is fixed by putting a 'synchronized' statement in
> LRUMemorycache.java
> 
> public void update(ICacheElement ce) throws IOException {
> 		// Asynchronisly create a MemoryElement
> 
> 		ce.getElementAttributes().setLastAccessTimeNow();
> 		
> 		MemoryElementDescriptor old = null;
> 		
> 		// the following operation has to be atomic 
>  	    synchronized (this) {
> 			addFirst(ce);
> 			old =
> (MemoryElementDescriptor)map.put(first.ce.getKey(), first);
> 	    }
> .....
> }
> 
> this mailing list is so quieeeeeeeeeet... 
> 
> > -----Original Message-----
> > From: Amy Wang [mailto:amy.wang@intersperse.com]
> > Sent: Thursday, August 21, 2003 6:52 PM
> > To: 'Turbine JCS Users List'; 'Turbine JCS Developers List'
> > Subject: Errors from LRUMemoryCache
> > 
> > 
> > Does anyone know what's happening here?
> > I got bunch of exceptions from LRUMemoryCache.
> > There is no object serialized to the disk cache. After this
> > error, many
> > objects are lost. 
> > What would have caused this problem? 
> > Much appreciated. 
> >  
> > 22:29:50,375 ERROR [LRUMemoryCache] key hashcode=1318941830 
> > 22:29:50,375 ERROR [LRUMemoryCache] key 
> > toString=omi.wm.is.IsService:host=hqdeva
> > pp004.intersperse.com,pkg=MultipleServices900,port=5555,svc=se
> > rvice18&#58;se
> > rvic
> > e18Copy2
> > 22:29:50,437 ERROR [LRUMemoryCache] 
> > verifycache[hqdevapp002_replicaRegionObjectM
> > ap]: map does not contain value : 
> > org.apache.jcs.engine.memory.lru.MemoryElement
> > Descriptor@1719f30
> > 22:29:51,265 ERROR [LRUMemoryCache] 
> > verifycache[hqdevapp002_replicaRegionObjectM
> > ap]: key not found in list : Keys
> > 22:29:51,281 ERROR [LRUMemoryCache] verifycache: map contains key 
> > 22:29:51,468 ERROR [LRUMemoryCache] 
> > verifycache[hqdevapp002_replicaRegionObjectM
> > ap]: map does not contain key : 
> > omi.wm.is.IsService:host=hqdevapp004.intersperse
> > .com,pkg=MultipleServices900,port=5555,svc=service18&#58;servi
> > ce18Copy2
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> turbine-jcs-dev-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> turbine-jcs-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org


Mime
View raw message