• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Not a Bug
  • ehcache-core
  • alexsnaps
  • Reporter: jkronegg
  • August 08, 2011
  • 0
  • Watchers: 1
  • July 27, 2012
  • August 10, 2011

Description

When ‘maxElementsOnDisk’ is not configured or is set to 0, the following warning message appears:

“Performance may degrade and server disks could run out of space! The distributed cache {CACHE_REGION_NAME} does not have maxElementsOnDisk set. Failing to set maxElementsOnDisk could mean no eviction of its elements from the Terracotta Server Array disk store. To avoid this, set maxElementsOnDisk to a non-zero value.”

A nice tips, but it is displayed even if disk cache is not used…

This occurs in [2.4.3 http://svn.terracotta.org/fisheye/browse/Ehcache/tags/ehcache-core-2.4.3/src/main/java/net/sf/ehcache/Cache.java?r=HEAD], but not in [2.4.2 http://svn.terracotta.org/fisheye/browse/Ehcache/tags/ehcache-core-2.4.2/src/main/java/net/sf/ehcache/Cache.java?r=HEAD] where the warning is not yet implemented. This is due to the check at [line 1050 http://svn.terracotta.org/fisheye/browse/Ehcache/tags/ehcache-core-2.4.3/src/main/java/net/sf/ehcache/Cache.java?r=4210#l1050]:
if (getCacheConfiguration().getMaxElementsOnDisk()==0) {
  Log.WARN("Performance may degrade and server disks could run out of space!\nThe distributed cache {} does not have " +
          "maxElementsOnDisk set. Failing to set maxElementsOnDisk could mean no eviction of its elements from the " +
          "Terracotta Server Array disk store. To avoid this, set maxElementsOnDisk to a non-zero value.", getName());
}

The condition should be rewritten to add a check on the disk usage (“isDiskStore() && “):

if (isDiskStore() && getCacheConfiguration().getMaxElementsOnDisk()==0) {

Comments

Julien Kronegg 2011-08-08

A workaround is to set ‘maxElementsOnDisk’ to 1 in ehcache.xml

Alexander Snaps 2011-08-10

This should only be logged if your cache is Terracotta clustered. If I am reading the code properly, line 1050 is itself contained within a “isTerracottaClustered” condition on line 1013. Are you saying you get the warning with non-TC clustered caches as well ?

Julien Kronegg 2011-08-10

No. The documentation (either from ehcache.xml or CacheConfiguration.java) describe ‘maxElementsOnDisk’ as “the maximum objects to be held in the DiskStore.”. Since ‘overflowToDisk’ and ‘diskPersistent’ are set to false, I did not expected that a DiskStore is created (so I did not expected that ‘maxElementsOnDisk’ is used).

When using in “Terracotta Clustered” mode, is a DiskStore created even ‘overflowToDisk’ and ‘diskPersistent’ are set to false ?

Julien Kronegg 2011-08-10

I found a better documentation in the [FAQ on available stores and configuration|http://ehcache.org/documentation/terracotta/faq.html#What_Stores_are_available_and_how_are_they_configured] : {quote} The Terracotta server provides an additional store, generally referred to as the Level 2 or L2 store.

The MemoryStore in JVM in the local node is referred to as the L1 Store.

maxElementsInMemory - the maximum number of elements in the local L1 store.

maxElementsOnDisk - is overridden when using Terracotta to provide the L2 size. The L2 size is effectively the maximum cache size.

overflowToDisk normally controls whether to overflow to the DiskStore. This is ignored when using Terracotta - the DiskStore is never used. When the store gets full, elements will always overflow to the Terracotta L2 Store running on the server. The L2 can be further configured with the tcconfig. {quote}

It seems that I was misleading the usage of maxElementsOnDisk when used for Terracotta Clustered. IMHO, ehcache.xml should also contains the FAQ text, otherwise it is misleading…

Alex: you may close the issue.

Alexander Snaps 2011-08-10

Right, maxElementsOnDisk controls the maximum size of the L2’s size for that Cache. Hence the warning: If you set this to 0, the cache will grow infinitely and potentially fill all the L2’s memory and disks, should the dataset be too big… So this all works as expected. The naming is confusing and will change in the future…