You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexey Goncharuk (JIRA)" <ji...@apache.org> on 2018/04/23 15:40:00 UTC

[jira] [Commented] (IGNITE-2888) Eviction policy not called upon cache.remove()

    [ https://issues.apache.org/jira/browse/IGNITE-2888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16448328#comment-16448328 ] 

Alexey Goncharuk commented on IGNITE-2888:
------------------------------------------

[~ilantukh] Ilya, can you please check if this issue is still relevant on ignite 2.x codebase?

> 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
>            Priority: Major
>
> 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
(v7.6.3#76005)