Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override cache's CacheManager - after restart of remote Hazelcast #12975

Closed
exmortal opened this issue Apr 25, 2018 · 1 comment
Closed

Cannot override cache's CacheManager - after restart of remote Hazelcast #12975

exmortal opened this issue Apr 25, 2018 · 1 comment

Comments

@exmortal
Copy link

@exmortal exmortal commented Apr 25, 2018

Hi everyone,

I faced with Cannot override cache's CacheManager exception when I tried to recreate a cache instance after I restarted remote Hazelcast. Hazelcast client successfully reestablished connection, but... all cache instances already using in application are inactive now. Any attempts to touch it will throw:

com.hazelcast.cache.CacheNotExistsException: Cache /hz/cache1 is already destroyed or not created yet...

To avoid that I tried to recreate each cache instance using new cache manager, because previous was closed due lost connection. First attempt to create a cache fails with:

java.lang.IllegalStateException: Cannot overwrite a Cache's CacheManager.
	at com.hazelcast.client.cache.impl.AbstractClientInternalCacheProxy.setCacheManager(AbstractClientInternalCacheProxy.java:173) ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.client.cache.impl.ClientCacheProxy.setCacheManager(ClientCacheProxy.java:94) ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.client.cache.impl.HazelcastClientCacheManager.createCacheProxy(HazelcastClientCacheManager.java:112) ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCacheUnchecked(AbstractHazelcastCacheManager.java:243) ~[hazelcast-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCache(AbstractHazelcastCacheManager.java:219) ~[hazelcast-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCache(AbstractHazelcastCacheManager.java:67) ~[hazelcast-3.9.3.jar:3.9.3]

My application uses JCache API to create caches, like this:

CachingProvider provider = Caching.getCachingProvider();
CacheManager manager = provider.getCacheManager();

Cache<K, V> cache = manager.getCache(cacheName);
if (cache != null) {
    return cache;
}
      
return manager.createCache(cacheName, configuration);       

This error happened because of this PR #11076
Any ideas how to invalidate all Cache instances on fly ? Or it's a bug ?

Thanks,
Vlad

@vbekiaris
Copy link
Contributor

@vbekiaris vbekiaris commented Jun 1, 2018

@exmortal thanks for the issue report. It is a bug and a fix PR (#13228) has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.