-
Enhancement
-
Resolution: Unresolved
-
Major
-
None
-
5.2.7.Final, 7.0.0.Final
-
None
using DefaultCacheManager#startCaches do not start a previously stopped cache:
CacheManager cacheManager = new DefaultCacheManager(); cacheManager.startCaches("abc"); Cache cache = cacheManager.getCache("abc"); cache.stop(); cacheManager.startCaches("abc"); cache = cacheManager.getCache("abc); cache.get("def"); // trow IllegalStateException
java.lang.IllegalStateException: Cache 'abc' is in 'TERMINATED' state and so it does not accept new invocations. Either restart it or recreate the cache container.
at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:110)
at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:92)
at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104)
at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:58)
at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:343)
at org.infinispan.CacheImpl.get(CacheImpl.java:289)
at org.infinispan.CacheImpl.get(CacheImpl.java:281)
I think the issue is in the thread that will call the createCache(cacheName).
By looking at the 7.0.0.Final source code:
String threadName = "CacheStartThread," + globalConfiguration.transport().nodeName() + "," + cacheName; Thread thread = new Thread(threadName) { @Override public void run() { try { createCache(cacheName); } catch (RuntimeException e) { exception.set(e); } catch (Throwable t) { exception.set(new RuntimeException(t)); } } };
I think we should do instead something like the following:
String threadName = "CacheStartThread," + globalConfiguration.transport().nodeName() + "," + cacheName; Thread thread = new Thread(threadName) { @Override public void run() { try { Cache cache = getCache(cacheName, false); if (cache == null) { createCache(cacheName); } else { if (ComponentStatus.TERMINATED.equals(cache.getStatus())) { cache.start(); } } } catch (RuntimeException e) { exception.set(e); } catch (Throwable t) { exception.set(new RuntimeException(t)); } } };
- is related to
-
ISPN-2418 CLONE - Cache restart doesn't work properly
- Closed