有个频繁做索引的应用,它同时也对外提供搜索服务。大部分是 solr 1.3 的默认配置。solr 做索引,有时候报:
2009-7-13 9:48:06 org.apache.solr.common.SolrException log
严重: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SingleInstanceLock: write.lock
at org.apache.lucene.store.Lock.obtain(Lock.java:85)
at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1140)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:938)
at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:116)
...
是写锁取不到。但重启 solr 又可以正常做,主要是运行时间长了就报这个错了。还是看下配置吧。
看到 solr 1.3 默认的配置是:
- <indexDefaults>
- <!-- ... -->
- <!--
- This option specifies which Lucene LockFactory implementation to use.
- single = SingleInstanceLockFactory - suggested for a read-only index
- or when there is no possibility of another process trying
- to modify the index.
- native = NativeFSLockFactory
- simple = SimpleFSLockFactory
- (For backwards compatibility with Solr 1.2, 'simple' is the default
- if not specified.)
- -->
- <lockType>single</lockType>
- </indexDefaults>
<indexDefaults> <!-- ... --> <!-- This option specifies which Lucene LockFactory implementation to use. single = SingleInstanceLockFactory - suggested for a read-only index or when there is no possibility of another process trying to modify the index. native = NativeFSLockFactory simple = SimpleFSLockFactory (For backwards compatibility with Solr 1.2, 'simple' is the default if not specified.) --> <lockType>single</lockType> </indexDefaults>
默认锁是 single ,只读的。solr 1.2 是 simple,把它改回去了,运行了几天,没事。