Re: using lucene Lock inter-jvm

2006-06-23 Thread Michael McCandless
OK, I did some digging on this ... using native locks has been
discussed before:

  * In this thread (2.5 yrs ago), to get locking across machines, a
pluggable locking framework was created.  This looks very clean as
it would allow, eg, single JVM instances of Lucene to use an
in-process lock w/ FSDirectory instead of filesystem based locks.
Locking is then independent of Directory implemenation in use:

 
http://www.gossamer-threads.com/lists/lucene/java-dev/24329?search_string=pluggable%20lock;#24329

This was then opened as an issue with nice patch:

  http://issues.apache.org/jira/browse/LUCENE-305

  * Also 2.5 yrs ago, this bug (separately) was opened, which looks
like a starvation issue (because there's no scheduling of lock
acquisitions), with a patch was that uses native locks:

  http://issues.apache.org/jira/browse/LUCENE-307

  * Then in this thread (2 yrs ago), native locks were explored as a
way to make locking over NFS work, but apparently (??) didn't
reach closure because the approach seemed to hang over NFS:

 
http://www.gossamer-threads.com/lists/lucene/java-dev/22464?search_string=FileLock;#22464

  * There in this thread (1.5 yrs ago) it seems this was the original
driver for switching from 1.3 to 1.4 (but then didn't happen):

 
http://www.gossamer-threads.com/lists/lucene/java-dev/25034?search_string=FileLock;#25034

It seems like:

  * Locking is a sore point now.  Just googling on the lock obtain
timed out produces quite a few results.

  * Most of these are probably from hard shutdowns (jvm crashed or was
killed, power lost to machine, etc) leaving lock files in the
filesystem, which native locking would automatically prevent.

  * Some of these cases are probably the thread starvation case
(LUCENE-307) maybe (speculating...) from frequent interleaving of
deleting docs via IndexReader  adding docs via IndexWriter.  With
the right Lock class we can resolve this.

  * Remote locking is a relatively common need but not supported now
(and native locking and/or pluggable locking w/ a DB or other
implementation, should be able to resolve).

I think the best course of action here is:

  * Let's first try to get the patches in LUCENE-305 updated to
current HEAD sources and then committed?  This can be done
independent of native locks, by having the current locking
implementation be the default Lock class for starters.

  * Next, create a native locking class that extends Lock.  Borrow /
copy / be inspired from the examples above (and also from Hadoop /
Jackrabbit and others).  Try to resolve other issues (the
starvation issue above; using wait/notify instead of sleep /
poll).  Add this to core or contrib, and at some point make it the
default Lock implementation for FSDirectory.

Does that sound right?  If so, how to nudge this forward?  There was
thread recently on voting for bugs to fix.  I vote +1 for LUCENE-305!

I'll volunteer to update LUCENE-305 to current HEAD unless original
author (or someone else) wants to?

Mike




Yonik Seeley [EMAIL PROTECTED] 
06/21/2006 11:53 AM
Please respond to
java-dev@lucene.apache.org


To
java-dev@lucene.apache.org
cc
java-user@lucene.apache.org
Subject
Re: using lucene Lock inter-jvm






On 6/21/06, Michael McCandless [EMAIL PROTECTED] wrote:
 Does anyone know of any reasons not to switch Lucene's FSDirectory 
locking
 to the java.nio.channels.FileLock?  EG, are there any performance issues
 that people are aware of?  It's available since Java 1.4.

Good question Michael, no reason that I know of... I think its
probably just that no one has revisited the issue since Lucene moved
to 1.4

-Yonik
http://incubator.apache.org/solr Solr, the open-source Lucene search 
server

-
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]



[jira] Commented: (LUCENE-307) Lock obtain time out errors when opening readers and writers

2006-06-23 Thread Andy Hind (JIRA)
[ 
http://issues.apache.org/jira/browse/LUCENE-307?page=comments#action_12417515 ] 

Andy Hind commented on LUCENE-307:
--

I have seen something similar.

When the lock file is deleted the return value is not checked.
I have seen cases where the lock file is left by this call when you would 
expect it to be deleted.

I suspect that checking the file exists or trying to create the lock file can 
prevent it from being deleted.
Other processes could also be preventing the deletion,  but not in my case.
It seems to be more likely under heavy lock load.

It would be simple to retry the delete and report an exception if the lock file 
could not eventually be deleted by the owner.

There is also no reason why there can not be a single shared lock of each type 
for the singe instance of the FSDirectory.
I suspect there are many use cases where all that is required is in-JVM locking.

I am all for lucene using nio locking and pluggable locking.

For in-JVM locking with nio you have to use the same file channel instance for 
locking. In this patch I do not think that is the case as a new RAF and channel 
instance will be created for each new lock instance.  




 Lock obtain time out errors when opening readers and writers
 

  Key: LUCENE-307
  URL: http://issues.apache.org/jira/browse/LUCENE-307
  Project: Lucene - Java
 Type: Bug

   Components: Other
 Versions: 1.4
  Environment: Operating System: All
 Platform: All
 Reporter: Reece (YT)
 Assignee: Lucene Developers
  Attachments: FSLock.java, TestLuceneLocks.java

 The attached Java file shows a locking issue that occurs with Lucene 1.4.2.
 One thread opens and closes an IndexReader.  The other thread opens an
 IndexWriter, adds a document and then closes the IndexWriter.  I would expect
 that this app should be able to happily run without an issues.
 It fails with:
   java.io.IOException: Lock obtain timed out
 Is this expected?  I thought a Reader could be opened while a Writer is 
 adding a
 document.
 I am able to get the error in less than 5 minutes when running this on Windows
 XP and Mac OS X.
 Any help is appreciated.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]