Search code examples
javacachingignitegridgain

Apache Ignite 2.7.5 delete cache and free up memory


We are using Apache Ignite (version 2.7.5) as a 2-node PARTITIONED cluster with ignite persistence enabled.

Each of the 2 ignite instances has a cache (say, named XYZ) which is taking up ~ 250 GB space in each of the instances. This table has 150 million records.

Going forward we don't need this cache any more and I want to delete this cache and reclaim space (disk space as well as off-heap memory) in each of the instances.

I have tried the following:

  1. Tried writing an API to remove all data from the cache and destroy it.

    @DeleteMapping(path = "/delete-cache")
     public String deleteCache() {
         try {
             IgniteCache<XYZId, XYZ> cache = ignite.cache("XYZCache");
             cache.removeAll();
             cache.destroy();
         } catch (Exception e) {
    
             LOG.error("Exception while destroying cache: ", e);
    
             return "Fail";
         }
         return "Success";
     }
    

    But on hitting this API, Ignite hangs and my service loses connection with Ignite.

  2. Tried deleting the cache by going inside the ignite instances and doing an rm cache-XYZ. After doing this the disk space got reclaimed by the ignite instances could never start up as a cluster together. There was no specific error in the ignite logs but doing an:

./control.sh --baseline did not give any result and the terminal hanged.

Currently, there is an API to delete the objects one by one given the id of the record, but this is going to take 8 weeks to delete 150 million entries with the current rate.

Is there a better way to achieve this?


Solution

  • You can run just cache.destroy(); (without deleting each entry) It will destroy the cache and reclaim the space on the disk.