From 0084c7e57cf6119c8be192718f5103419760415e Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sat, 9 Aug 2008 20:27:24 +0000 Subject: [PATCH] SOLR-687: only unlockOnStartup the first time for each dir git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@684333 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/solr/core/SolrCore.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index 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 dirs = new HashSet(); + + // currently only called with SolrCore.class lock held void 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);