solr 做索引时报 Lock obtain timed out: SingleInstanceLock: write.lock

有个频繁做索引的应用,它同时也对外提供搜索服务。大部分是 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 默认的配置是:

  1. <indexDefaults>  
  2.     <!-- ... -->  
  3.     <!--  
  4.       This option specifies which Lucene LockFactory implementation to use.  
  5.   
  6.       single = SingleInstanceLockFactory - suggested for a read-only index  
  7.                or when there is no possibility of another process trying  
  8.                to modify the index.  
  9.       native = NativeFSLockFactory  
  10.       simple = SimpleFSLockFactory  
  11.   
  12.       (For backwards compatibility with Solr 1.2, 'simple' is the default  
  13.        if not specified.)  
  14.     -->  
  15.     <lockType>single</lockType>  
  16. </indexDefaults>  

默认锁是 single ,只读的。solr 1.2 是 simple,把它改回去了,运行了几天,没事。

posted @ 2009-09-16 12:13  searchDM  阅读(950)  评论(0编辑  收藏  举报