I am fairly new to Lucene, so forgive my elaborate explanation. We were facing frequent issues with Lucene 1.2 (Unreleased write.lock() files). To overcome the same, we have recently upgraded to Lucene 2.3.2 - however, we observed the following LockObtainFailedException exception during our testing -
2009-02-26 15:34:35,525 DEBUG [com.eu.prnewswire.search.document.WDPIndexDocument] Document() called
2009-02-26 15:34:35,529 DEBUG [com.eu.prnewswire.search.document.WDPIndexDocument] adding associated type
2009-02-26 15:34:35,529 DEBUG [com.eu.prnewswire.search.document.WDPIndexDocument] added
2009-02-26 15:34:36,535 ERROR [STDERR] org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out:
2009-02-26 15:34:36,536 ERROR [STDERR]  at org.apache.lucene.store.Lock.obtain(Lock.java:85)
2009-02-26 15:34:36,536 ERROR [STDERR]  at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:692)
2009-02-26 15:34:36,536 ERROR [STDERR]  at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:503)

2009-02-26 15:34:36,536 ERROR [STDERR]  at com.eu.prnewswire.search.index.LuceneIndex.addDocument(LuceneIndex.java:124)
2009-02-26 15:34:36,536 ERROR [STDERR]  at
2009-02-26 15:34:36,536 ERROR [STDERR]  at
2009-02-26 15:34:36,536 ERROR [STDERR]  at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
2009-02-26 15:34:36,536 ERROR [STDERR]  at
2009-02-26 15:34:36,536 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:324)
2009-02-26 15:34:36,536 ERROR [STDERR]  at org.jboss.invocation.Invocation.performCall(Invocation.java:359)

  From the stack trace, we can trace back the exception to the following code in the IndexWriter class (while trying to acquire a lock):
Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);
if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
    throw new LockObtainFailedException("Index locked for write: " + writeLock);

  We have seen this issue only once till now and the files did not index until we deleted the lock file manually. (When I checked for existing issues, Lucene-715 came closest, but it has been resolved in 2.1 version) I am afraid this may crop up sometime again. Any inputs on how to resolve the the error would be appreciated. If any more details are required, I would be happy to share the same.

Bollywood news, movie reviews, film trailers and more! Click here.