diff --git a/VERSION b/VERSION index 0d92a1028..7caaea437 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5 +1.16.6-B1 diff --git a/src/main/groovy/io/seqera/wave/store/cache/AbstractTieredCache.groovy b/src/main/groovy/io/seqera/wave/store/cache/AbstractTieredCache.groovy index 3a79fd8b5..724942e00 100644 --- a/src/main/groovy/io/seqera/wave/store/cache/AbstractTieredCache.groovy +++ b/src/main/groovy/io/seqera/wave/store/cache/AbstractTieredCache.groovy @@ -25,7 +25,9 @@ import java.util.concurrent.locks.ReentrantLock import java.util.function.Function import com.github.benmanes.caffeine.cache.AsyncCache +import com.github.benmanes.caffeine.cache.AsyncLoadingCache import com.github.benmanes.caffeine.cache.Cache +import com.github.benmanes.caffeine.cache.CacheLoader import com.github.benmanes.caffeine.cache.Caffeine import com.github.benmanes.caffeine.cache.RemovalCause import com.github.benmanes.caffeine.cache.RemovalListener @@ -63,7 +65,15 @@ abstract class AbstractTieredCache implements TieredCac private L2TieredCache l2 - private final WeakHashMap locks = new WeakHashMap<>() + // FIXME https://github.com/seqeralabs/wave/issues/747 + private AsyncLoadingCache locks = Caffeine.newBuilder() + .maximumSize(5_000) + .weakKeys() + .buildAsync(loader()) + + CacheLoader loader() { + (String key) -> new ReentrantLock() + } AbstractTieredCache(L2TieredCache l2, MoshiEncodeStrategy encoder) { if( l2==null ) @@ -76,7 +86,7 @@ abstract class AbstractTieredCache implements TieredCac if( _l1!=null ) return _l1.synchronous() - final sync = locks.computeIfAbsent('sync-l1', (k)-> new ReentrantLock()) + final sync = locks.get('sync-l1').get() sync.lock() try { if( _l1!=null ) @@ -171,7 +181,7 @@ abstract class AbstractTieredCache implements TieredCac return value } - final sync = locks.computeIfAbsent(key, (k)-> new ReentrantLock()) + final sync = locks.get(key).get() sync.lock() try { value = l1Get(key)