当前位置:首页 > 开发 > 编程语言 > 搜索 > 正文

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

发表于: 2014-07-19   作者:zwllxs   来源:转载   浏览:
摘要: 有一次更新完代码启动系统,系统报如下异常: java.lang.RuntimeException: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@D:\opt\xxxx_index\place\write.lock at com.xxxx.vst.searc
有一次更新完代码启动系统,系统报如下异常:
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模块要慎用,因为它会悄悄神不知鬼不知自己悄悄被调用

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

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号