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:[EMAIL PROTECTED] > 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:[EMAIL PROTECTED] > 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:[EMAIL PROTECTED] > > 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: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 > > [EMAIL PROTECTED] > > 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:servi > > ce18Copy2 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
