You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by jacky <ja...@gmail.com> on 2006/09/27 09:02:20 UTC

lock file of lucene

hi,
  When writing into an index, lucene will create a write lock file. 
So, if there is an error during the writing. the lock file will not be deleted. 
And also the JVM will not be closed for some time. So the program will have no chance to get lock of this index.
Is there any method to avoid that?

     Best Regards.
       jacky  
       

Re: lock file of lucene

Posted by Michael McCandless <lu...@mikemccandless.com>.
Bhavin Pandya wrote:
> Before you open IndexWriter object you can check whether lock file 
> exists or not and if its available you can unlock it.
> Use IndexReader.isLocked and IndexReader.unlock.

Also, you could use a try / finally and always close the IndexWriter in
the finally clause, which should release the lock.  However, it sounds
like something else is up if you are hitting alot of errors when writing
the index.

We are working on a locking implementation that uses OS native locks
(instead of file existence locking now used).  This would fix the case
where the JVM has crashed or was killed (ie, the OS will release the
lock for us).

Mike

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


Re: lock file of lucene

Posted by jacky <ja...@gmail.com>.
hi,
   yes, but there maybe several programs to write the index. 
If a program is writing into the index, the index database maybe corrupted 
when another program unlocks it

     Best Regards.
       jacky  
       
----- Original Message ----- 
From: "Bhavin Pandya" <bh...@rediff.co.in>
To: <ja...@lucene.apache.org>
Sent: Wednesday, September 27, 2006 4:55 PM
Subject: Re: lock file of lucene


> Hi jacky,
> 
> Before you open IndexWriter object you can check whether lock file exists or 
> not and if its available you can unlock it.
> Use IndexReader.isLocked and IndexReader.unlock.
> 
> - Bhavin pandya
> 
> 
> ----- Original Message ----- 
> From: "jacky" <ja...@gmail.com>
> To: <ja...@lucene.apache.org>
> Sent: Wednesday, September 27, 2006 12:32 PM
> Subject: lock file of lucene
> 
> 
> > hi,
> >  When writing into an index, lucene will create a write lock file.
> > So, if there is an error during the writing. the lock file will not be 
> > deleted.
> > And also the JVM will not be closed for some time. So the program will 
> > have no chance to get lock of this index.
> > Is there any method to avoid that?
> >
> >     Best Regards.
> >       jacky
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 

Re: lock file of lucene

Posted by Bhavin Pandya <bh...@rediff.co.in>.
Hi jacky,

Before you open IndexWriter object you can check whether lock file exists or 
not and if its available you can unlock it.
Use IndexReader.isLocked and IndexReader.unlock.

- Bhavin pandya


----- Original Message ----- 
From: "jacky" <ja...@gmail.com>
To: <ja...@lucene.apache.org>
Sent: Wednesday, September 27, 2006 12:32 PM
Subject: lock file of lucene


> hi,
>  When writing into an index, lucene will create a write lock file.
> So, if there is an error during the writing. the lock file will not be 
> deleted.
> And also the JVM will not be closed for some time. So the program will 
> have no chance to get lock of this index.
> Is there any method to avoid that?
>
>     Best Regards.
>       jacky
> 


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