akakike
akakike

Reputation: 23

Oracle Coherence fast empty complete cluster

I'm having problems with a cache cluster to empty all cache data stores.

This cluster has 89 cache stores and lasts more than 40 minutes to completely unload data.

I'm using this function:

public void deleteAll() {
    try {
        getCache().clear();
    } catch (Exception e) {
        log.error("Error unloading cache",getCache().getCacheName());
    }
}

getCache Method retrieves a NamedCache of CacheFactory.

public NamedCache getCache() {
    if (cache == null) {
        cache = com.tangosol.net.CacheFactory.getCache(this.idCacheFisica);
    }

    return cache;
}

Has anyone found any other way to do this faster?

Thank you in advance,

Upvotes: 0

Views: 1387

Answers (2)

cpurdy
cpurdy

Reputation: 1236

Often, a "bulk operation" call like clear() will get transmitted all the way back to the backing maps as a bulk operation, but will at some point (somewhere inside the server code) become a iteration-based implementation, so that each entry being removed can be evaluated against any registered rules, triggers, event listeners, etc., and so that backups can be captured exactly. In other words, to guarantee "correctness" in a distributed environment, it slows down the operation and forces it to occur as some ordered sequence of sub-operations.

Some of the reasons why this would happen:

  1. You've configured read-through, write-through and/or write-behind behavior for the cache;
  2. You have near caches and/or continuous queries (which imply listeners);
  3. You have indexes (which need to be updated as the data disappears);
  4. etc.

I will ask for some suggestions on how to speed this up.

Update (14 July 2014) - Yes, it turns out that this is a known issue (i.e. that it could be optimized), but that to maintain both "correctness" and backwards compatibility, the optimizations (which would be significant changes) have been deferred, and the clear() is still done in an iterative manner on the back end.

Upvotes: 0

Nick Holt
Nick Holt

Reputation: 34311

It's strange it would take so long, though to be honest, it's unusual to call clear.

You could try destroying the cache with NamedCache.destroy or CacheFactory.destroy(NamedCache).

The only problem with this is that it invalidates any references that there might be to the cache, which would need to be re-obtained with another call the CacheFactory.getCache.

Upvotes: 2

Related Questions