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 Chuck Williams <ch...@manawiz.com> on 2006/03/13 08:22:02 UTC

Failure recovery

Is there a way to determine whether or not an index that was left locked
due to some improper system shutdown needs repair?

My code does the following as part of starting up and creating an
IndexWriter for an existing index that was created in a prior session:

>         if (IndexReader.isLocked(index.indexDirectory)) {
>             // ***** TODO add a test for a valid index, if possible
>             log.error("Forcibly unlocking the index directory for
> investigation " + investigation.getName() + ".  Ensure it is not
> corrupt!");
>             IndexReader.unlock(index.indexDirectory);
>         }


The occurrence of this condition indicates the system did not shutdown
cleanly in the prior run.  I'd like to know whether the index is valid
or not before blindly unlocking it.

Thanks for any help,

Chuck


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


Re: Failure recovery

Posted by Yonik Seeley <ys...@gmail.com>.
On 3/13/06, Chuck Williams <ch...@manawiz.com> wrote:
> Is there a way to determine whether or not an index that was left locked
> due to some improper system shutdown needs repair?

Depends what you mean by "repair".  If there was a crash during index
modification, I think the index should normally still be OK because
the segments file won't refer to the new segments that were being
written during the crash, right?

However, you may be missing documents that were added last, and there
may be files left around that are unused by the index.

-Yonik
http://incubator.apache.org/solr Solr, The Open Source Lucene Search Server

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