lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (Commented) (JIRA)" <>
Subject [jira] [Commented] (SOLR-2801) IndexNotFoundException thrown when the index directory has no segments file
Date Mon, 03 Oct 2011 17:33:35 GMT


Hoss Man commented on SOLR-2801:

Aat first glance this seems like a bad idea to me -- wouldn't this just silently hide some
file corruption?

I'd rather folks monitoring Solr get a scary error that requires rebuilding or restoring data
from backups then to just suddenly have most of their index be gone and not know that they
should rebuild/restore
> IndexNotFoundException thrown when the index directory has no segments file
> ---------------------------------------------------------------------------
>                 Key: SOLR-2801
>                 URL:
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 3.4
>            Reporter: Ruben Inoto
>            Priority: Trivial
> If the directory where the index is stored gets somehow corrupted, and it becomes empty
or the segments files are deleted, any attempt to access the Solr server (via /select, /update,
etc..) will throw the following exception:
> {code}
> org.apache.lucene.index.IndexNotFoundException: no segments* file found in
> {code}
> The only workaround we have found is to stop the server, remove the /index directory,
and start again.
> We have found more useful to create a new implementation of the IndexReaderFactory (that
extends StandardIndexReaderFactory), that, in case of a IndexNotFoundException, it tries to
"fix" the index directory by opening an IndexWriter on it and doing a commit:
> {code}
>     @Override
>     public IndexReader newReader(Directory indexDir, boolean readOnly) throws IOException
>         try {
>             return super.newReader(indexDir, readOnly);
>         } catch (IndexNotFoundException e) {
>             logger.warn(
>                     "Warning: Trying to get a new reader threw an exception. Trying to
create a writer first, and then get the reader",
>                     e);
>             IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_34, new WhitespaceAnalyzer(
>                     Version.LUCENE_34));
>             config.setOpenMode(OpenMode.CREATE_OR_APPEND);
>             IndexWriter writer = new IndexWriter(indexDir, config);
>             writer.commit();
>             writer.close();
>             try {
>                 return super.newReader(indexDir, readOnly);
>             } catch (IndexNotFoundException e2) {
>                 logger.error(
>                         "Trying to commit in the writer didn't work, as the reader is
still throwing an exception :(. Re-throwing exception",
>                         e2);
>                 throw e2;
>             }
>         }
>     }
> {code}
> Would it make sense to add something like this to the StandardIndexReaderFactory?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message