Author |
Message |
08/14/2012 05:36:59
|
nestrada
journeyman
Joined: 08/20/2010 06:13:31
Messages: 37
Location: Paris, France
Offline
|
Hello,
I'm running into an odd bug that occurred when I migrated from an eternal=true cache (for testing) to an eternal=false cache for integration testing and production. It doesn't happen all the time but enough for it to be somewhat of a show stopper.
I'm essentially capturing a snapshot of the cache by performing the following operations: cache.getAll(cache.getKeys()) (At the moment I don't use the getKeysWithExpiryCheck() as I'm hoping the returned Map will show me the Elements which are expired.
However I'm getting this exception
Code:
java.lang.UnsupportedOperationException: putInternal is supported only for existing keys
at org.terracotta.modules.ehcache.store.backend.GetAllCustomMap.put(GetAllCustomMap.java:92)
at org.terracotta.modules.ehcache.store.backend.GetAllCustomMap.put(GetAllCustomMap.java:20)
at net.sf.ehcache.Cache.searchAllInStoreWithStats(Cache.java:2065)
at net.sf.ehcache.Cache.getAll(Cache.java:1614)
at org.greendays.cache.cluster.ClusteredCacheMap.getAll(ClusteredCacheMap.java:315)
at org.greendays.cache.cluster.ClusteredCacheSortedMap.getAll(ClusteredCacheSortedMap.java:120)
at org.greendays.cache.cluster.ClusteredCacheMap.getValueSnapshot(ClusteredCacheMap.java:355)
...
I'm pretty sure that now that I have expired key entries this changes things but throwing such an blocking exception I don't understand. Any help would be much appreciated.
Nicolas
|
|
|
08/14/2012 12:07:15
|
grenfro
neo
Joined: 06/25/2012 09:35:52
Messages: 8
Offline
|
Can you share your ehcache.xml. I am unable to reproduce the issue.
|
|
|
08/14/2012 16:32:39
|
ssubbiah
jedi
Joined: 05/24/2006 14:25:22
Messages: 117
Location: Saravanan Subbiah
Offline
|
Please open a jira and add the logs, config and if possible a reproducible test case so that we can track this issue.
|
Saravanan Subbiah
Terracotta Engineer |
|
|
08/15/2012 08:12:40
|
amaheshw
neo
Joined: 08/14/2012 20:48:42
Messages: 4
Offline
|
Can you explain your use case in more detail with ehcache.xml and sample piece of code to reproduce this issue?
Are you preparing a keyCollection outside and then calling cache.getAll(keyCollection) or you are calling cache.getAll(cache.getKeys()). I can imagine this stack trace when keyCollection is prepared outside and modified while cache.getAll() is still not complete.
|
|
|
08/23/2012 09:40:27
|
nestrada
journeyman
Joined: 08/20/2010 06:13:31
Messages: 37
Location: Paris, France
Offline
|
I'm working on a reproducible test case (although I admit I'm sticking to eternal for now as I have other priorities) but in short here is my code (Guava needed), maybe you can spot the culprit ;) To be knowledge I'm NOT modifying the keys collection during the method invocation.
Code:
...
public Collection<V> getValueSnapshot() {
return getAll(cache.getKeys()).values();
}
public Map<K,V> getAll(Collection<?> keys) throws NullPointerException {
if (keys.isEmpty()) { return Collections.emptyMap(); }
Map snapshot = Maps.filterEntries(cache.getAll(keys), NonNullElement.INSTANCE);
return Maps.transformValues(snapshot, new Function<Element,V>() {
public V apply(Element input) {
return (V) input.getObjectValue();
}
});
}
private static final class NonNullElement implements Predicate<Map.Entry<?,Element>> {
static final NonNullElement INSTANCE = new NonNullElement();
public boolean apply(Map.Entry<?,Element> input) {
return input.getValue() != null;
}
}
|
|
|
08/23/2012 11:18:20
|
amaheshw
neo
Joined: 08/14/2012 20:48:42
Messages: 4
Offline
|
Approximately how many keys you have in your code? I iterated 100 time your getValueSnapshot() for 5000 keys but was not able to hit any exception.
Just to be sure, can you modify your getValueSnapshot() as suggested below and see if you still hit that exception in your code?
Code:
public Collection<V> getValueSnapshot() {
Collection<V> keys = Collections.unmodifiableCollection(new HashSet(cache.getKeys()));
return getAll(keys).values();
}
|
|
|
|