Apache Lucene open-source search software
SOLR-4001: In CachingDirectoryFactory#close, if there are still refs for a Directory outstanding, we need to wait for them to be released before closing.
Mark Robert Millera00e1ab23dab
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 24c9aae8cac..0f1b44d767a 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -125,6 +125,10 @@ Bug Fixes* SOLR-3998: Atomic update on uniqueKey field itself causes duplicate document.(Eric Spencer, yonik)+* SOLR-4001: In CachingDirectoryFactory#close, if there are still refs for a+ Directory outstanding, we need to wait for them to be released before closing.+ (Mark Miller)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.javaindex c1804ae7d07..8c74928b886 100644--- a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java+++ b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java@@ -111,6 +111,17 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {synchronized (this) {for (CacheValue val : byDirectoryCache.values()) {try {+ // if there are still refs out, we have to wait for them+ int cnt = 0;+ while(val.refCnt != 0) {+ wait(100);++ if (cnt++ >= 100*10*30) {+ log.error("Timeout waiting for all directory ref counts to be released");+ break;+ }+ }+assert val.refCnt == 0 : val.refCnt;val.directory.close();} catch (Throwable t) {