How to handle Hibernate-Search index recovery?

☆樱花仙子☆ 提交于 2019-12-12 12:37:00

问题


When an application server exits unexpectedly, Hibernate Search can not do a graceful shutdown of Lucene. Leaving write.lock files behind in each index directory. That is of course quite normal. But - the lock files also remain after restarting the application. Which causes lock timeout exceptions at some time.

My question is whether there is a usual way to handle the recovery.

What comes first at mind would be to check for the presence of write.lock files. If one is found, they are removed and all indices are rebuilt. But maybe Hibernate-Search does this automatically when properly configured ?


回答1:


if Hibernate Search were to remove lock files at boot, it might risk to destroy your index if by mistake you configured two applications to run on the same index. Hence not deleting the lock file is the purpose of the lock.

Still, we realized this was annoying: if you can use the Native LockFactory ( http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html_single/#search-configuration-directory-lockfactories ) even a crashed / killed JVM will release the lock files.

If you upgrade to latest versions, Native is used by default if the detected platform is considered safe enough.



来源:https://stackoverflow.com/questions/9771127/how-to-handle-hibernate-search-index-recovery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!