views:

669

answers:

2

Hi,

Am a newbie to Lucene search API. I keep getting following exception when updating Lucene index...why do i get this error and how do i avoid it?

System.IO.IOException: Lock obtain timed out: SimpleFSLock@C:\Indexes\write.lock
   at Lucene.Net.Store.Lock.Obtain(Int64 lockWaitTimeout)
   at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, Boolean closeDir)
   at Lucene.Net.Index.IndexWriter.Init(String path, Analyzer a, Boolean create)
   at Lucene.Net.Index.IndexWriter..ctor(String path, Analyzer a, Boolean create)

Thanks for reading.

+5  A: 

Lucene creates lock file when the index is opened in write mode. This lock file is removed when you cleanly close the index. While writing the index, if the program exits without closing the lucene IndexWriter, you will get this exception next time when you try to write to it. If you remove the lock file from the index directory, you will not see this exception.

You can choose to disable the locking with FSDirectory.setDisableLocks(false) but that is not advisable as the errors are being ignored silently.

Shashikant Kore
A: 

I think you can also get this error if an index write takes longer than the timeout value and another index write comes along after the lock expires and before the index write finishes - at least it seemed like that was what was happening.

I started having that same problem when I started approaching 50% or so of the maximum number of files in a single Windows directory. This slowed writes down enough to cause the problem. (Win2k3)

I believe that you can recompile Lucene to change the timeout value.

R Ubben
Can you please answer this one?http://stackoverflow.com/questions/899542/problem-using-same-instance-of-indexsearcher-for-multiple-requests
Steve Chapman