lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DMGoodst...@lbl.gov
Subject Re: Multiple Creation of Writers
Date Wed, 14 Jan 2004 18:08:18 GMT
use standard java synchronization (either
method-syncrhonization or block-level
synchronization) to make sure that only one thread
at a time can perform the check for index existence.
 The test for an existing index and the subsequent
creation of an IndexWriter should occur in the same
synchronized block of code.

--David Goodstein
  Computational Biology Group
  Joint Genome Institute



----- Original Message -----
From: David Townsend <david.townsend@magus.co.uk>
Date: Wednesday, January 14, 2004 9:48 am
Subject: Multiple Creation of Writers

> In my system indices are created and updated by
multiple threads.  
> I need to check if an index exists to decide
whether to pass true 
> or false to the IndexWriter constructor.
> 
> new IndexWriter(FSDirectory, Analyzer, boolean);
> 
> The problem arises when two threads attempt to
create the same 
> index after simultaneously finding that the index
does not exist.  
> This problem can be reproduced in a single thread by
> 
> writerA = new IndexWriter(new
File("c:/import/test"), new 
> StandardAnalyzer(), true);
> writerB = new IndexWriter(new
File("c:/import/test"), new 
> StandardAnalyzer(), true);
> add1000Docs(writerA);
> add1000Docs(writerB);
> 
> this will throw an IOException
> 
> C:\import\test\_a.fnm (The system cannot find the
file specified)
> 
> The only solution I can think of is to create a
database/file lock 
> to get around this, or change the Lucene code to
obtain a lock 
> before creating an index.  Any ideas?
> 
> David
> 
> 
> 
> 
> 
> 
> 
> 
>
--------------------------------------------------------------------
> -
> To unsubscribe, e-mail:
lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
lucene-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message