简体   繁体   中英

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

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM