Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-4187

LRU eviction algorithm does not evict the eldest entry

    XMLWordPrintable

Details

    Description

      The following test for JDBC cache stores fails:

      @Test
          @WithRunningServer({@RunningServer(name = CONTAINER1, config = CONFIG_FETCH_STATE_1)})
          public void testFetchState() throws Exception {
              try {
                  mc1 = createMemcachedClient(server1);
                  assertCleanCacheAndStore1();
                  mc1.set("k1", "v1");
                  mc1.set("k2", "v2");
                  mc1.set("k3", "v3");
                  assertNotNull(dbServer1.stringTable.getValueByKey("k1"));
                  startContainer(controller, CONTAINER2, CONFIG_FETCH_STATE_2);
                  mc2 = createMemcachedClient(server2);
                  assertTrue(0 < server2.getCacheManager(MANAGER_NAME).getCache(CACHE_NAME).getNumberOfEntries());
                  //the cache store should fetch state from the others
                  //since eviction.max-entries==2, first k2 and k3 is loaded from the other cache, then k1 is loaded
                  //from the other cache's loader and thus k2 is evicted and ends up in a cache loader
                  assertNull(dbServer2.stringTable.getValueByKey("k1"));
                  assertEquals("v1", mc2.get("k1"));
                  assertEquals("v2", mc2.get("k2"));
                  assertNull(dbServer2.stringTable.getValueByKey("k1"));
      //^^^^^fails here, the K1 was evicted even though it was used recently
      //K3 was supposed to be evicted but it did not happen
                  assertNull(dbServer2.stringTable.getValueByKey("k2"));
                  assertCleanCacheAndStore2();
              } finally {
                  controller.stop(CONTAINER2);
              }
          }
      

      This tests works properly if the following commit is reverted, so it was caused by this commit:
      https://github.com/infinispan/infinispan/commit/b190230d84beb41474bae0239c181a5f0e95f30c

      Note that there's another commit with the same name but different commit hash: b71da1c

      The test above can be run from https://github.com/chepa653/infinispan/tree/t_ISPN-3904 by going to server/integration/testsuite and running mvn clean verify -Dtest=StringBasedStoreMultinodeTest#testFetchState -Dlog.level.infinispan=TRACE

      Attachments

        Activity

          People

            wburns@redhat.com Will Burns
            mgencur Martin Gencur
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: