lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Best Locking approach (Directory Lock)
Date Wed, 02 Dec 2009 13:45:55 GMT
Currently the sole usage of the LockFactory within Lucene is for the
write.lock, ie, to prevent more than one writer (= IndexWriter, or,
IndexReader trying to do deletions or set norms) from being open on
the index at once.

If your app has external mechanisms that can ensure, without fail,
that only one writer will be open at once, then NoLockFactory is
perfectly safe.

But you have to be certain: one slipup will quickly corrupt the index.
 IndexWriters are like the male Siamese fighting fish (betta fish) --
they will fight to the death [of the index]!

Mike

On Wed, Dec 2, 2009 at 8:24 AM, Shai Erera <serera@gmail.com> wrote:
> I have multiple JVMs on different machines accessing the shared file system.
> I don't really have multiple IndexWriters on the same JVM, I asked this just
> out of curiosity.
>
> So I don't understand from your reply if it's safe to use NoLockFactory, or
> I should use SimpleFSLockFactory and unlock if needed?
>
> Shai
>
> On Wed, Dec 2, 2009 at 3:03 PM, Uwe Schindler <uwe@thetaphi.de> wrote:
>
>> Hi Shai,
>>
>> > have other uses as well? What about multiple IndexWriters from the same
>> > JVM?
>>
>> This also needs a lock. But if it is guaranteed to only have one JVM
>> accessing the index, you can use an in-JVM-Locking mechanism which is
>> provided by
>>
>> http://lucene.apache.org/java/3_0_0/api/all/org/apache/lucene/store/SingleIn
>> stanceLockFactory.html<http://lucene.apache.org/java/3_0_0/api/all/org/apache/lucene/store/SingleIn%0AstanceLockFactory.html>
>>
>> > If NoLockFactory is not safe, then we can move to SimpleFSLockFactory,
>> and
>> > since we can guarantee by other means that only one IndexWriter attempts
>> > to
>> > write to the index, we can IndexWriter.unlock(Dir) if the lock exists.
>>
>> If you can guarantee that you only have *one* JVM and there may be multiple
>> IndexWriters, use above solution.
>>
>> Uwe
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>

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


Mime
View raw message