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

The size of a local cache could be more accurate under concurrent modifications when expiration is enabled

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 4.1.0.CR3, 4.1.0.Final
    • 4.0.0.Final, 4.1.0.CR1
    • None
    • None

    Description

      I'm totally aware that the cache size is an approximation according to your doc however the value could be improved if in the class DefaultDataContainer in case of cache entry expiration, you first check if the method remove(key) returns a non null value before decrementing the variable numEntries as below otherwise you could decrement it several times for the same entry:

      `
      if (mortalEntries.remove(k) != null) {
        numEntries.getAndDecrement();            
      }
      

      I attached a test case in which I set maxIdle to 0 to make the issue happens more easily. I also attached a patch proposal, it is up to you to apply it or reject it.

      Attachments

        1. ISPN-536.diff
          3 kB
        2. TestCacheSize.java
          7 kB
        3. TestCacheSize.java
          6 kB

        Activity

          People

            manik_jira Manik Surtani (Inactive)
            nfilotto Nicolas Filotto (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: