Lucene的IndexWriter初始化时报Lock obtain timed out: NativeFSLock_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Lucene的IndexWriter初始化时报Lock obtain timed out: NativeFSLock

Lucene的IndexWriter初始化时报Lock obtain timed out: NativeFSLock

 2014/7/20 12:40:26  zwllxs  程序员俱乐部  我要评论(0)
  • 摘要:有一次更新完代码启动系统,系统报如下异常:java.lang.RuntimeException:org.apache.lucene.store.LockObtainFailedException:Lockobtaintimedout:NativeFSLock@D:\opt\xxxx_index\place\write.lockatcom.xxxx.vst.search.lucene.search.Searcher.init(Searcher.java:74)atcom.xxxx.vst
  • 标签:lucene
有一次更新完代码启动系统,系统报如下异常:
class="java" name="code">
java.lang.RuntimeException: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@D:\opt\xxxx_index\place\write.lock
	at com.xxxx.vst.search.lucene.search.Searcher.init(Searcher.java:74)
	at com.xxxx.vst.search.lucene.search.Searcher.<init>(Searcher.java:53)
	at com.xxxx.vst.search.lucene.LuceneContext.init(LuceneContext.java:51)
	at com.xxxx.vst.search.listener.LuceneContextIniter.contextInitialized(LuceneContextIniter.java:21)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@D:\opt\xxxx_index\place\write.lock
	at org.apache.lucene.store.Lock.obtain(Lock.java:84)
	at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:644)
	at com.xxxx.vst.search.lucene.search.Searcher.init(Searcher.java:65)
	... 18 more


经查,IndexWriter的构造函数在试图获取另外一个IndexWriter已经加锁的索引目录时就会抛出一个LockObtainFailedException。但是我们系统中并没有多个IndexWriter去指定同一个目录,走查代码才发现,原来是同一个初始化方法调用了两次,一次是spring监听器里调用的,另一个是另一同事测试方便,在static模块里调用的,导致同一个lucene上下文初始化方法被调用两次,建议static模块要慎用,因为它会悄悄神不知鬼不知自己悄悄被调用
发表评论
用户名: 匿名