[infinispan-dev] Passivation and BCHM WAS: fixing eviction with transactions (critical for Hibernate Search)

Mircea Markus mircea.markus at jboss.com
Fri Jun 17 06:03:54 EDT 2011


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/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java#L341
> 
> 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/org/infinispan/eviction/EvictionManager.java#L61
> 
> which in turn passivates the evicted entries:
> 
> https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java#L189
> 
> 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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/infinispan-dev/attachments/20110617/c240d32c/attachment-0001.html 


More information about the infinispan-dev mailing list