Apache Solr open-source search software
SOLR-687: only unlockOnStartup the first time for each dir
Yonik Seeley0084c7e57cf6
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.javaindex f8f5a4cfd11..f0184d4cfa7 100644--- a/src/java/org/apache/solr/core/SolrCore.java+++ b/src/java/org/apache/solr/core/SolrCore.java@@ -259,13 +259,17 @@ public final class SolrCore {}+ // protect via synchronized(SolrCore.class)+ private static Set<String> dirs = new HashSet<String>();++ // currently only called with SolrCore.class lock heldvoid initIndex() {try {File dirFile = new File(getIndexDir());boolean indexExists = dirFile.canRead();-+ boolean firstTime = dirs.add(dirFile.getCanonicalPath());boolean removeLocks = solrConfig.getBool("mainIndex/unlockOnStartup", false);- if (indexExists && removeLocks) {+ if (indexExists && firstTime && removeLocks) {// to remove locks, the directory must already exist... so we create it// if it didn't exist already...Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), solrConfig.mainIndexConfig);