[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-998) Unlock at startup using SimpleFSLockFactory
David Polo (JIRA)
noreply at atlassian.com
Fri Dec 2 03:44:22 EST 2011
Unlock at startup using SimpleFSLockFactory
-------------------------------------------
Key: HSEARCH-998
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-998
Project: Hibernate Search
Issue Type: Bug
Components: massindexer
Affects Versions: 4.0.0.CR2
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
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
More information about the hibernate-issues
mailing list