It looks to me like you are not sharing an IndexSearcher across threads. You really should, or use a small pool of them (depending on speed/ram/load).

The only time I usually see this error, I also see too many files open first. Are you sure you don't have another exception as well?



Paul J. Lucas wrote:
I occasionally get a FileNotFoundException like:

Exception in thread "Thread-44" org.apache.lucene.index.MergePolicy$MergeException: java.io.FileNotFoundException: /Stuff/Caches/AuroraSupport/IM_IndexCache/INDEX/_27.cfs (No such file or directory) at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:271) Caused by: java.io.FileNotFoundException: /Stuff/Caches/AuroraSupport/IM_IndexCache/INDEX/_27.cfs (No such file or directory)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at org.apache.lucene.store.FSDirectory$FSIndexInput$Descriptor.<init>(FSDirectory.java:506) at org.apache.lucene.store.FSDirectory$FSIndexInput.<init>(FSDirectory.java:536) at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:445) at org.apache.lucene.index.CompoundFileReader.<init>(CompoundFileReader.java:70) at org.apache.lucene.index.SegmentReader.initialize(SegmentReader.java:277)
    at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:262)
    at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:221)
at org.apache.lucene.index.IndexWriter.mergeMiddle(IndexWriter.java:3263)
    at org.apache.lucene.index.IndexWriter.merge(IndexWriter.java:2968)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:240)

I'm currently using the 2.3.2 version of Lucene. The exception frequency has decreased since upgrading from 2.3.1.

My code runs in a server that monitors the filesystem. Whenever the contents of a directory change, my code unindexes all the files in the changed directory, then reindexes all the files in the directory.

I'm not doing anything complicated in my code. To create/open the index, I do:

    INDEX_DIR = new File( INDEX_CACHE_DIR, "INDEX" );
    INDEX = FSDirectory.getDirectory( INDEX_DIR );
    if ( IndexReader.isLocked( INDEX ) )
        IndexReader.unlock( INDEX );

The isLocked()/unlock() is because sometimes the server process gets killed and leaves teh indexed locked.

I have a thread than handles the unindexing/reindexing. It gets changed from a BlockingQueue. My unindex code is like:

    IndexWriter writer = new IndexWriter( INDEX, INDEX_ANALYZER, false );
    final Term t = new Term( DIR_FIELD, dir.getAbsolutePath() );
    writer.deleteDocuments( t );
    writer.close();

My indexing code is like:

    IndexWriter writer = new IndexWriter( INDEX, INDEX_ANALYZER );
    writer.setMergeFactor( INDEX_MERGE_FACTOR );
    Document doc = new Document();
    // ... add fields to doc ...
    writer.addDocument( doc );
    writer.close();

While that thread is executing, other threads can search the index by doing:

    IndexSearcher searcher = new IndexSearcher( INDEX );
    // ... prepare Query and Sort ...
    Hits hits = searcher.search( query, sort );
    Iterator hitIterator  hits.iterator();
    // ... iterate over hitIterator ...
    searcher.close();

Any ideas?  Is this a bug in Lucene?

- Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to