lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vitaly Funstein <vfunst...@gmail.com>
Subject Calling IndexWriter.commit() immediately after creating the writer
Date Thu, 30 May 2013 00:09:59 GMT
I have encountered a strange issue, that appears to be pretty hard to hit,
but is still a serious problem when it does occur. It seems that if the JVM
crashes in a racy fashion with instantiation of IndexWriter, the index may
be left in an inconsistent state. An attempt to reload such an index on
restart will result in a CorruptIndexException thrown when calling the
constructor again.

My idea of a workaround involves the following:

- call commit() immediately after invoking the constructor.
- create a special init file after the commit to indicate the index was
created successfully
- on app startup, check to see if the init file is there; if not, the index
is corrupt and needs to be recreated.

(The last two already happen in my code)

Is this a valid approach to protect from this sort of race? Is there
already a built-in mechanism to make constructor fully synchronous wrt
persisting all the metadata? If not, it seems like there probably should
be...

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message