How to handle Hibernate-Search index recovery?

When the application server shuts down unexpectedly, Hibernate Search cannot gracefully shutdown Lucene. Leaving write.lock files behind in every index directory. This is, of course, quite normal. But - blocking files also remain after restarting the application. Which raises lock timeout exceptions for some time.

My question is if there is a common way to handle recovery.

First of all, the mind will check for the existence of write.lock files. If found, they are dropped and all indexes are rebuilt. But maybe Hibernate-Search does this automatically when configured correctly?


source to share

1 answer

if Hibernate Search were supposed to delete lock files on load, you may be at risk of destroying your index if you mistakenly configured two applications to work with the same index. Therefore, not deleting the lock file is the purpose of the lock.

However, we realized that this is annoying: if you can use Native LockFactory ( ) even a crashed / killed JVM will release lock files.

If you are upgrading to the latest versions, Native is used by default if the discovered platform is deemed secure enough.



All Articles