You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Xin Herbert Wu <xi...@pathf.com> on 2006/01/19 05:35:41 UTC

" Lock obtain timed out" Exception when doing incremental indexing

I kept getting this exception when adding a new document to an existing
index:

 

22:19:10,281 INFO  [STDOUT] java.io.IOException: Lock obtain timed out:
Lock@C:\DOCUME~1\xin\LOCALS~

1\Temp\lucene-31c482aaf5f581ad3dc0249eeeb8d281-write.lock

 

(Stack trace is like:

22:19:10,312 INFO  [STDOUT]     at
org.apache.lucene.store.Lock.obtain(Lock.java:58)

22:19:10,312 INFO  [STDOUT]     at
org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:223)

22:19:10,312 INFO  [STDOUT]     at
org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:173)

)

 

It does not seem affecting the search results most time, but I am not sure
how to get rid of it, and no trace to locate the lock file indicated in the
log file.

 

Any help is greatly appreciated.

 

The attached is the code to add a doc.

 

-Xin

public synchronized int addRecord(IndexDataSource dataSource, int recordId,
List<LibraryField> libSchema, String indexDir) throws IndexException {

 

       IndexWriter writer = null;

       int totalIndexed =0;

 

        try {

            .

            writer = new IndexWriter(indexDir, getAnalyzer(), false);

            writer.setUseCompoundFile(isCompound());

            

            writer.addDocument(doc);

                

            writer.optimize();

            totalIndexed = writer.docCount();

                           

            }

              

        } catch (IOException ioe) {

           

            throw new IndexException(ioe.toString());

            

        } finally {

            try {

                if (null != writer)

                {

                    writer.close();

                }

            } catch (IOException ioe) {

                throw new IndexException(ioe.toString()); 

            }

        }

 

        return totalIndexed;