Details
-
Type:
Bug
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 0.7
-
Fix Version/s: None
-
Component/s: CACHE
-
Labels:None
Description
In essence, the AbstractCachingInterceptor.invoke() works like this:
------------------------------------
Object cached = cache.getFromCache(key, model);
if (null == cached)
return cachedValueFromSource(mi, key, model);
return unmaskNull(cached);
------------------------------------
If two (or more) threads calls getFromCache() at the same time with the same key and the object is not in the cache yet, it's very likely that both threads will proceed and put the results to the cache twice, which is something that the cache wants to avoid in the first place.
Is this a known issue in the cache module? Synchronize the invoke() method will avoid this issue but it will not scale at all so do not think it's a good idea.
Looks to me this is a very common issue, yet i do not see a good solution. Are people just ignoring this problem because 1) it will only happen under load. 2) Even if it happens, it's just inefficient, the cache is not corrupted.
Here is the discussion on the forum:
http://forum.springframework.org/showthread.php?t=32689