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 <[EMAIL PROTECTED]>
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:
[EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]