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 Ravi Rao <rr...@alterpoint.com> on 2004/07/23 18:56:50 UTC

write lock: cleaning an index

All,

I have an application that has one IndexWriter.  Once in a while the
enclosing application is taken down with a kill and IndexWriter leaves
a lock file behind.  Other than removing the lock file, is there
anything else I can do to clean the index.

The only general solution I can think of is to index to a temporary
index and then every so often merge it with the master index, which
cannot be allowed to be corrupted.  In this scheme we lose only the
temporary index rather than the master index.

Many thanks,
-- 
Ravi/




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


Re: write lock: cleaning an index

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Uh, that's rough on IndexWriter, killing it like that. :(  One simple
solution to your problem may be gentler with IndexWriter, and design
your application in a way that will allow you to notify it when you
want to stop indexing and close IndexWriter.  One frequently used and
simple approach is to use the file system as your messaging mechanism.

To the application that uses IndexWriter, add a bit of code that
periodically looks for some file (e.g. stop-indexing).  Then add a bit
of logic around IndexWriter that will allow you to close it.  Combine
the two and you will be able to close IndexWriter with its close()
method when you create that stop-indexing file in the file system. 
This way you won't be leaving any locks behind, and there will be no
danger of corrupting the index.  Don't remember to remove the
stop-indexing file before re-starting your indexing application.


Otis


--- Ravi Rao <rr...@alterpoint.com> wrote:
> All,
> 
> I have an application that has one IndexWriter.  Once in a while the
> enclosing application is taken down with a kill and IndexWriter
> leaves
> a lock file behind.  Other than removing the lock file, is there
> anything else I can do to clean the index.
> 
> The only general solution I can think of is to index to a temporary
> index and then every so often merge it with the master index, which
> cannot be allowed to be corrupted.  In this scheme we lose only the
> temporary index rather than the master index.
> 
> Many thanks,
> -- 
> Ravi/
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
> 


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