Under what conditions is it safe to do I/O operations (move/replace) on a lucene index (compass)

101 views Asked by At

Sometimes there is need to re-build a lucene-index from scratch. As I do not want the index to be incomplete for several hours while building, I am using a separate compass instance to build the new index and replace it in the filesystem afterwards. Before doing so, all compass instances are stopped using SearchEngineIndexManager#stop(), afterwards they are restarted using SearchEngineIndexManager#start()

However, every now and then, the index seems to get corrupted during this operations.

Is it not safe to replace an index in the filesystem when the SearchEngineIndexManger is stopped? Are there any other necessary precautions to consider if I need to operate on a lucene index in the file system?

2

There are 2 answers

0
peterp On BEST ANSWER

I managed to fix the problem by adding 5 seconds of sleep after stopping and before re-starting the IndexManager. Might be an ugly solution, but works for me.

To be sure, I have also added a call to SearchEngineIndexManager#clearCache() after re-starting.

2
Bohemian On

What about putting your server into read-only mode then start a reindex on a second lucene instance (that has its own index). When finished indexing, shutdown all servers and give the new index to your main lucene sever.