[ https://issues.apache.org/jira/browse/SOLR-2801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ruben Inoto closed SOLR-2801. ----------------------------- Resolution: Not A Problem > IndexNotFoundException thrown when the index directory has no segments file > --------------------------------------------------------------------------- > > Key: SOLR-2801 > URL: https://issues.apache.org/jira/browse/SOLR-2801 > 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 > org.apache.lucene.store.NIOFSDirectory@/index_dir > {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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org