[
https://hibernate.onjira.com/browse/HSEARCH-998?page=com.atlassian.jira.p...
]
Sanne Grinovero commented on HSEARCH-998:
-----------------------------------------
I don't think we can differentiate. In fact I don't think we should do this by
default, but having the option would make some people happier.
I wonder though since we now default to using native locks, even a crashed instance should
cleanup the locks. So this is likely not needed anymore?
[HSEARCH-1022]
Unlock at startup using SimpleFSLockFactory
-------------------------------------------
Key: HSEARCH-998
URL:
https://hibernate.onjira.com/browse/HSEARCH-998
Project: Hibernate Search
Issue Type: New Feature
Components: massindexer
Environment: Java 1.6, Hibernate Search 4.0.0.CR2 on Oracle Database 10g
Enterprise Edition Release 10.2.0.3.0 - 64bits
Reporter: David Polo
Labels: hibernate
I'm using SimpleFSLockFactory and I'm getting this exception after an unexpected
shutdown of the application during indexation:
org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out
The workaround consists in executing this code at startup in order to unlock the
indexes:
FullTextSession fullTextSession = Search.getFullTextSession(hbSession);
MutableSearchFactory searchFactory = (MutableSearchFactory) fullTextSession
.getSearchFactory();
IndexReader indexReader = fullTextSession.getSearchFactory()
.getIndexReaderAccessor().open("");
Map<Class<?>, EntityIndexBinder> indexBindingsForEntity =
searchFactory
.getIndexBindingForEntity();
for (EntityIndexBinder eib : indexBindingsForEntity.values()) {
IndexManager[] indexManagers = eib.getIndexManagers();
DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager)
indexManagers[0];
Directory indexDirectory = indexManager.getDirectoryProvider()
.getDirectory();
if (IndexWriter.isLocked(indexDirectory)) {
IndexWriter.unlock(indexDirectory);
}
}
I have a single application that executes this code at startup so I think it's safe
to unlock the Directory at this time.
I'm doing this because I'm using SimpleFSLockFactory and it leaves write.lock
files.
I need to unlock at startup because I think using NativeFSLockFactory is not an option
for me (I'm using NFS).
It will be a good thing if Hibernate Search have an "unlock at startup" option.
It could be used only in cases like this (not all cases!).
In Solr there is an option:
<unlockOnStartup>true</unlockOnStartup>
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira