On 10 Jun 2011, at 13:42, Manik Surtani wrote:
So I've taken on this sub-task from Sanne (ISPN-1169), and here
is the deal:
BCHM analyses whether or not to evict stuff every time an operation (put, get, replace)
is run, based on the configured eviction policy (LIRS, LRU or NONE). It does so by
calling evictionStrategy.execute(), which returns a Set of hash entries removed from the
BCHM.
https://github.com/infinispan/infinispan/blob/master/core/src/main/java/o...
Note that execute() actually removes entries from the BCHM, so after execute() is called,
these entries are no longer in the BCHM!
This is set is then sent to the EvictionManager
https://github.com/infinispan/infinispan/blob/master/core/src/main/java/o...
which in turn passivates the evicted entries:
https://github.com/infinispan/infinispan/blob/master/core/src/main/java/o...
So we have a window where the entry is neither accessible from memory or from a cache
store, since it is "in-fly".
My proposed fix is to:
1) Make sure the PassivationManager is passed in to the DataContainer, and available to
any EvictionStrategy
2) EvictionStrategies ensure passivation occurs *before* removing an entry from the BCHM
Does this cover the following scenario?
1. thread1.get determines that K needs to be passivated
2. thread2 remove(k) removes it from memory
3. thread1. passivates it to disk then removes it from memory as well (no op)
4. thread3.read(k) returns a value - wrong.
I think this won't happen as along as we have a lock on K for the
passivate-then-delete-from-data-container operation. AFIK we don't do that ATM.