ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Avihai Berkovitz (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-2888) Eviction policy not called upon cache.remove()
Date Thu, 24 Mar 2016 13:37:25 GMT
Avihai Berkovitz created IGNITE-2888:
----------------------------------------

             Summary: Eviction policy not called upon cache.remove()
                 Key: IGNITE-2888
                 URL: https://issues.apache.org/jira/browse/IGNITE-2888
             Project: Ignite
          Issue Type: Bug
          Components: cache
    Affects Versions: 1.5.0.final
         Environment: java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
Windows 10 64bit
            Reporter: Avihai Berkovitz


When I set an eviction policy to a cache it doesn't get called when removing an entry from
the cache. This only happens when using a *REPLICATED* or *PARTITIONED* cache, and only in
*ATOMIC* mode. This is the reason it never came up in the GridCacheConcurrentEvictionConsistencySelfTest
test. If you change the cache parameters in the test you can see the problem easily.
This causes two problems:
* Cache entries that were deleted still remain in memory, because the objects are referenced
by the policy
* The eviction policy "thinks" the cache is larger than it really is, so entries might be
evicted even if there is no need for it

Here is a small test case to illustrate the problem:
{code}
IgniteConfiguration igniteConfig = new IgniteConfiguration()
        .setGridLogger(new Slf4jLogger())
        .setDeploymentMode(DeploymentMode.CONTINUOUS);
try (Ignite ignite = Ignition.start(igniteConfig)) {
    LruEvictionPolicy evictionPolicy = new LruEvictionPolicy(30);
    CacheConfiguration<String, String> cacheConfiguration = new CacheConfiguration<String,
String>()
            .setName("test")
            .setCacheMode(CacheMode.REPLICATED)
            .setAtomicityMode(CacheAtomicityMode.ATOMIC)
            .setEvictionPolicy(evictionPolicy);
    IgniteCache<String, String> cache = ignite.getOrCreateCache(cacheConfiguration);

    for (int i = 1; i <= 100; i++) {
        cache.put("key" + i, "data");
        System.out.println(String.format("Size: %d, LRU: %d", cache.size(CachePeekMode.ALL),
evictionPolicy.getCurrentSize()));
        if (i % 5 == 0) {
            cache.remove("key" + (i-1));
            System.out.println(String.format("Size: %d, LRU: %d", cache.size(CachePeekMode.ALL),
evictionPolicy.getCurrentSize()));
        }
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message