-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
I'm using the asMap().computeIfAbsent API on the LocalCache and under high concurrency AssertionError is being thrown. The issue also seems to be intermittent.
Cache instantiation
final Cache<Long, ILogData> readCache = CacheBuilder.newBuilder()
.maximumSize(5000)
.expireAfterAccess(30, TimeUnit.SECONDS)
.expireAfterWrite(30, TimeUnit.SECONDS)
.recordStats()
.build();Usage:
ILogData data = readCache.getIfPresent(address);
if (data == null) {
final ILogData loadedVal = fetch(address);
return readCache.asMap().computeIfAbsent(address, (k) -> loadedVal);
} else {
return data;
}Stacktrace :
java.lang.AssertionError at com.google.common.cache.LocalCache$Segment.getNextEvictable(LocalCache.java:2653) at com.google.common.cache.LocalCache$Segment.evictEntries(LocalCache.java:2637) at com.google.common.cache.LocalCache$Segment.storeLoadedValue(LocalCache.java:3158) at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2316) at com.google.common.cache.LocalCache$Segment.compute(LocalCache.java:2250) at com.google.common.cache.LocalCache.compute(LocalCache.java:4196) at com.google.common.cache.LocalCache.computeIfAbsent(LocalCache.java:4203) at org.corfudb.runtime.view.AddressSpaceView.read(AddressSpaceView.java:254) at