On Wed, Mar 9, 2011 at 2:44 PM, bart_212 <wojtekg...@gmail.com> wrote: > Hi, > I have two web applications that uses lucene 2.3.2. Both share the same > index and can write or read. Writing is synchronized based on file system to > allow only one IndexWriter to work at the moment. There can be multiple > IndexReader. IndexReader is stored and before searching, there is done > #reopen on it. IndexWriter can add/delete group of documents and can > optimize the index while searching is performed (multiple threads can > search). > I'm wondering if these operations are thread safe and don't corrupt the > index? I have observed the following exception when one IndexWriter was > adding and one IndexReader was reopened to search:
This usage is [supposed to be] perfectly fine. Any ops you do with IW while IRs are in use, IR is being opened/reopened, is fine. You can even open a new IW with create=true while IRs are in use. > java.io.FileNotFoundException: /tmp/test/index/_7y.tis > RandomAccessFile.open(String, int) line: not available [native method] > FSDirectory$FSIndexInput$Descriptor(RandomAccessFile).(File, String) line: > 212 > FSDirectory$FSIndexInput$Descriptor.(File, String) line: 506 > FSDirectory$FSIndexInput.(File, int) line: 536 > FSDirectory.openInput(String, int) line: 445 > TermInfosReader.(Directory, String, FieldInfos, int) line: 61 > SegmentReader.initialize(SegmentInfo, int, boolean) line: 317 > SegmentReader.get(Directory, SegmentInfo, SegmentInfos, boolean, boolean, > int, boolean) line: 262 > SegmentReader.get(SegmentInfo) line: 197 > MultiSegmentReader.(Directory, SegmentInfos, boolean, SegmentReader[], > int[], Map) line: 109 > MultiSegmentReader.doReopen(SegmentInfos) line: 203 > DirectoryIndexReader$2.doBody(String) line: 98 > DirectoryIndexReader$2(SegmentInfos$FindSegmentsFile).run() line: 636 > MultiSegmentReader(DirectoryIndexReader).reopen() line: 92 > IndexReaderManager.reopenReader(FileProxy, IndexReader) line: 92 > IndexReaderManager.getIndexReader(FileProxy) line: 76 > IndexSearcherFactory.createIndexSearcher(FileProxy) line: 66 This is definitely not good. Is the index otherwise healthy? Like this error is transient and later on opening a reader succeeds? What locking are you using to ensure the two IWs don't open the index at the same time? Just the default locking for your Directory impl? Which Directory impl are you using...? What filesystem is the index on? It looks like /tmp which is presumably a local filesystem right? -- Mike http://blog.mikemccandless.com --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org