Apache Solr open-source search software
SOLR-686: single lock factory overwrites previous (multicore reload corruption possibility)_
Yonik Seeley8e0503b66782
diff --git a/example/solr/conf/solrconfig.xml b/example/solr/conf/solrconfig.xmlindex 34f27639c7a..68aeddfcbdb 100755--- a/example/solr/conf/solrconfig.xml+++ b/example/solr/conf/solrconfig.xml@@ -88,12 +88,14 @@specify one of the other Lucene LockFactory implementations inthe event that you have a custom situation.- none = NoLockFactory (typically only used with read only indexes)- single = SingleInstanceLockFactory (suggested)+ single = SingleInstanceLockFactory - suggested for a read-only index+ or if there is no possibility of another process trying+ to modify the index.native = NativeFSLockFactorysimple = SimpleFSLockFactory- ('simple' is the default for backwards compatibility with Solr 1.2)+ (For backwards compatibility with Solr 1.2, 'single' is the default+ if not specified.)--><lockType>single</lockType></indexDefaults>diff --git a/src/java/org/apache/solr/update/SolrIndexWriter.java b/src/java/org/apache/solr/update/SolrIndexWriter.javaindex 24c520ced72..721fc89326c 100644--- a/src/java/org/apache/solr/update/SolrIndexWriter.java+++ b/src/java/org/apache/solr/update/SolrIndexWriter.java@@ -21,12 +21,7 @@ import org.apache.lucene.index.IndexWriter;import org.apache.lucene.index.MergePolicy;import org.apache.lucene.index.MergeScheduler;import org.apache.lucene.index.LogMergePolicy;-import org.apache.lucene.store.Directory;-import org.apache.lucene.store.FSDirectory;-import org.apache.lucene.store.NativeFSLockFactory;-import org.apache.lucene.store.NoLockFactory;-import org.apache.lucene.store.SimpleFSLockFactory;-import org.apache.lucene.store.SingleInstanceLockFactory;+import org.apache.lucene.store.*;import org.apache.solr.common.SolrException;import org.apache.solr.schema.IndexSchema;@@ -94,12 +89,16 @@ public class SolrIndexWriter extends IndexWriter {final String lockType = rawLockType.toLowerCase().trim();if ("simple".equals(lockType)) {+ // multiple SimpleFSLockFactory instances should be OKd.setLockFactory(new SimpleFSLockFactory(path));} else if ("native".equals(lockType)) {d.setLockFactory(new NativeFSLockFactory(path));} else if ("single".equals(lockType)) {- d.setLockFactory(new SingleInstanceLockFactory());+ if (!(d.getLockFactory() instanceof SingleInstanceLockFactory))+ d.setLockFactory(new SingleInstanceLockFactory());} else if ("none".equals(lockType)) {+ // recipie for disaster+ log.severe("CONFIGURATION WARNING: locks are disabled on " + path);d.setLockFactory(new NoLockFactory());} else {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,