1
votes

We are using Apache Ignite for caching and during testing i came accross this error

java.lang.IllegalStateException: Cache has been closed or destroyed

We have a Spring Restful client with IGNITE embedded inside. Calls come to update and remove from cache.

The Steps that happened are as follow

  1. One instance of Ignite server running.
  2. one instance of Restful client running on different server with Ignite Embedded.
  3. Killed the Ignite server instance, client still running
  4. Ignite server restarted.
  5. Any attempt by client to put a value in the cache leads to above exception.
  6. If Client is restarted everything works as normal

Can some one throw some insight as in why this is happening. Do i have to handle that event of all nodes leaving and manually evict cache or something.

Any help is appeciated

2

2 Answers

3
votes

In case all servers go down, client rejoins with a new ID (just like if you restart it manually). In this case all existing cache instances are closed and you have to get new ones (use Ignite.cache(...) method).

There is a ticket to improve this behavior: https://issues.apache.org/jira/browse/IGNITE-2766

1
votes

We also ran into this problem and we have a work-around. We implemented our own version of SpringCacheManager (ReconnectSafeSpringCacheManager) that wraps the cache objects in reconnect-safe cache proxy objects (ReconnectSafeCacheProxy).

When an IllegalStateException is caught by one of the cache proxies, we tell our cache manager to drop that cache (remove it from the internal caches map) and then we call ReconnectSafeSpringCacheManager.getCache(<cacheName>) which recreates the Ignite cache instance. The proxy replaces its cache reference with the new Ignite cache and then the operation that caused the exception is retried.

Our approach required us to place our cache manager code in the org.apache.ignite.cache.spring package as there are references to non-public API:s in SpringCacheManager, which isn't the cleanest approach but it seems to work and we plan to remove the work-around when IGNITE-2786 is resolved.