diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 88236ed63e0..6cd52911487 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -157,6 +157,8 @@ Bug Fixes * SOLR-10063: CoreContainer shutdown has race condition that can cause a hang on shutdown. (Mark Miller) +* SOLR-10104: BlockDirectoryCache release hooks do not work with multiple directories. (Mike Drob, Mark Miller) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java index 7a5c67c78a2..f00ca1ddaf4 100644 --- a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java +++ b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java @@ -17,6 +17,8 @@ package org.apache.solr.store.blockcache; import java.nio.ByteBuffer; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; import com.github.benmanes.caffeine.cache.Cache; @@ -38,8 +40,8 @@ public class BlockCache { private final int numberOfBlocksPerBank; private final int maxEntries; private final Metrics metrics; - private volatile OnRelease onRelease; - + private final List onReleases = new CopyOnWriteArrayList<>(); + public static interface OnRelease { public void release(BlockCacheKey blockCacheKey); } @@ -95,7 +97,7 @@ public class BlockCache { location.setRemoved(true); locks[bankId].clear(block); lockCounters[bankId].decrementAndGet(); - if (onRelease != null) { + for (OnRelease onRelease : onReleases) { onRelease.release(blockCacheKey); } metrics.blockCacheEviction.incrementAndGet(); @@ -239,6 +241,6 @@ public class BlockCache { } void setOnRelease(OnRelease onRelease) { - this.onRelease = onRelease; + this.onReleases.add(onRelease); } } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 81e1f224ef2..7eb9b0d2e1e 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -457,7 +457,7 @@ public class MiniSolrCloudCluster { } } finally { executor.shutdown(); - executor.awaitTermination(2, TimeUnit.SECONDS); + executor.awaitTermination(15, TimeUnit.SECONDS); try { if (!externalZkServer) { zkServer.shutdown();