• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • hsingh
  • Reporter: mads1980
  • May 24, 2010
  • 0
  • Watchers: 2
  • January 17, 2013
  • May 25, 2010

Attachments

Description

Please see the following code at DiskStore.evictLfuDiskElements():

private void evictLfuDiskElements(int count) {
    synchronized (diskElements) {
        for (int i = 0; i < count; i++) {
            DiskElement diskElement = findRelativelyUnused();
            diskElements.remove(diskElement.key);
            notifyEvictionListeners(diskElement);
            freeBlock(diskElement);
        }
    }
}

The field diskElements is a ConcurrentHashMap, so synchronization on the instance would not be necessary, at least not for maintaining Map consistency. Even if it were necessary for any other reasons, this is the only block of code synchronizing on this mutex. As far as I can see, the only possible stack trace would be:

-> flushSpool() -> writeOrReplaceEntry() -> evictLfuDiskElements()

flushSpool() is already synchronized on the DiskStore’s implicit instance mutex, so there’s no possibility of concurrently reaching the synchronized (diskElements) block.

Comments

Manuel Dominguez Sarmiento 2010-05-25

DiskStore patch including mods for EHC-721, EHC-722, EHC-723, EHC-725, and EHC-726

Himadri Singh 2010-06-27

Tweaked patch has been checked in.