What I really want to do is add documents to the same index from several 
different computers/processes so I can't use any shared memory or resources.
As a result I can't use any normal locking mechanism. I thought since Lucene 
uses file-based locking this might just work.

Am I missing something here?


-----Original Message-----
From: Jeff [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2008 16:31 PM
To: lucene-net-user@incubator.apache.org
Subject: Re: Multi process writer access to an index

IndexWriter is not threadsafe. What you can do though is index the files on
seperate threads and put them into a RAMDirectory[] and use a single
IndexWriter to add them using AddIndexes(Directory[]).

On Thu, Mar 20, 2008 at 10:06 AM, Eran Sevi <[EMAIL PROTECTED]> wrote:

> I moved to 2.1 although it's not declared as "final".
>
> Still, I get the following exception:
>
> Lock obtain timed out: [EMAIL PROTECTED]:\Temp\xml\Lucene\MTIndex\write.lock
>   at Lucene.Net.Store.Lock.Obtain(Int64 lockWaitTimeout) in
> D:\C#\src\Lucene.Net\Store\Lock.cs:line 85
>   at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean
> create, Boolean closeDir) in D:\C#\src\Lucene.Net\Index\IndexWriter.cs:line
> 437
>   at Lucene.Net.Index.IndexWriter.Init(FileInfo path, Analyzer a, Boolean
> create) in D:\C#\src\Lucene.Net\Index\IndexWriter.cs:line 421
>   at Lucene.Net.Index.IndexWriter..ctor(FileInfo path, Analyzer a, Boolean
> create) in D:\C#\src\Lucene.Net\Index\IndexWriter.cs:line 297
>   at Nice.Analytics.Lucene.AAIndexer.RunThread(Object data) in
> D:\LuceneWrapper\Indexer.cs:line 158
>   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>   at System.Threading.ExecutionContext.Run(ExecutionContext
> executionContext, ContextCallback callback, Object state)
>   at System.Threading.ThreadHelper.ThreadStart(Object obj)
>
> I run 2 threads which doesn't share any object between them. Both succeed
> at creating an instance of a new IndexWriter on the same folder but fail
> when trying to Close the index.
> I tried setting the lockWaitTimeout to 300000 but the exception is thrown
> immediately.
>
>
> -----Original Message-----
> From: Digy [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 19, 2008 18:37 PM
> To: lucene-net-user@incubator.apache.org
>  Subject: RE: Multi process writer access to an index
>
> Which version do you use?.This bug exists in version 2.0.
> You can get the latest version 2.1 from svn.
>
> DIGY.
>
>
> -----Original Message-----
> From: Eran Sevi [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 19, 2008 12:17 PM
> To: lucene-net-user@incubator.apache.org
> Subject: Multi process writer access to an index
>
> Hi,
> Using the latest Lucene.Net release I encounter exceptions when trying to
> write to the same index from different processes/threads.
>
> The errors are about accessing the deletable file which is being used by
> another process.
>
> I don't perform any specific locking because as I understand it there
> should
> be file-specific locking mechanism used by lucene API. This doesn't seem
> to
> be working as I am able to instantiate an IndexWriter on the same index
> simultaneously, but I encounter problems when I try to close/optimize it .
>
> Here's an example of what I do in each process/thread:
>
> writer = new IndexWriter(fi, new StandardAnalyzer(threadData.stopwords),
> true);
> while (currentFile < threadData.files.Length)
>            {
>                //Add document
>                AddDocument(threadData.files[currentFile], writer);
>
> writer.Close();
>
> currentFile++;
>            }
>
> Please help me understand if lucene doesn't support this kind of access,
> and
> what's the proper way to write to the same index from two or more
> different
> processes/computers.
>
> Thanks,
> Eran S.
>
>
>

Reply via email to