mirror of https://github.com/apache/lucene.git
SOLR-686: single lock factory overwrites previous (multicore reload corruption possibility)_
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@684339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0084c7e57c
commit
8e0503b667
|
@ -88,12 +88,14 @@
|
||||||
specify one of the other Lucene LockFactory implementations in
|
specify one of the other Lucene LockFactory implementations in
|
||||||
the event that you have a custom situation.
|
the event that you have a custom situation.
|
||||||
|
|
||||||
none = NoLockFactory (typically only used with read only indexes)
|
single = SingleInstanceLockFactory - suggested for a read-only index
|
||||||
single = SingleInstanceLockFactory (suggested)
|
or if there is no possibility of another process trying
|
||||||
|
to modify the index.
|
||||||
native = NativeFSLockFactory
|
native = NativeFSLockFactory
|
||||||
simple = SimpleFSLockFactory
|
simple = 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>
|
<lockType>single</lockType>
|
||||||
</indexDefaults>
|
</indexDefaults>
|
||||||
|
|
|
@ -21,12 +21,7 @@ import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.MergePolicy;
|
import org.apache.lucene.index.MergePolicy;
|
||||||
import org.apache.lucene.index.MergeScheduler;
|
import org.apache.lucene.index.MergeScheduler;
|
||||||
import org.apache.lucene.index.LogMergePolicy;
|
import org.apache.lucene.index.LogMergePolicy;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.*;
|
||||||
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.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.schema.IndexSchema;
|
import org.apache.solr.schema.IndexSchema;
|
||||||
|
|
||||||
|
@ -94,12 +89,16 @@ public class SolrIndexWriter extends IndexWriter {
|
||||||
final String lockType = rawLockType.toLowerCase().trim();
|
final String lockType = rawLockType.toLowerCase().trim();
|
||||||
|
|
||||||
if ("simple".equals(lockType)) {
|
if ("simple".equals(lockType)) {
|
||||||
|
// multiple SimpleFSLockFactory instances should be OK
|
||||||
d.setLockFactory(new SimpleFSLockFactory(path));
|
d.setLockFactory(new SimpleFSLockFactory(path));
|
||||||
} else if ("native".equals(lockType)) {
|
} else if ("native".equals(lockType)) {
|
||||||
d.setLockFactory(new NativeFSLockFactory(path));
|
d.setLockFactory(new NativeFSLockFactory(path));
|
||||||
} else if ("single".equals(lockType)) {
|
} else if ("single".equals(lockType)) {
|
||||||
|
if (!(d.getLockFactory() instanceof SingleInstanceLockFactory))
|
||||||
d.setLockFactory(new SingleInstanceLockFactory());
|
d.setLockFactory(new SingleInstanceLockFactory());
|
||||||
} else if ("none".equals(lockType)) {
|
} else if ("none".equals(lockType)) {
|
||||||
|
// recipie for disaster
|
||||||
|
log.severe("CONFIGURATION WARNING: locks are disabled on " + path);
|
||||||
d.setLockFactory(new NoLockFactory());
|
d.setLockFactory(new NoLockFactory());
|
||||||
} else {
|
} else {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
|
|
Loading…
Reference in New Issue