[hibernate-issues] [Hibernate-JIRA] Updated: (HSEARCH-998) Unlock at startup using SimpleFSLockFactory

Sanne Grinovero (JIRA) noreply at atlassian.com
Fri Dec 2 05:06:19 EST 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sanne Grinovero updated HSEARCH-998:
------------------------------------

    Suitable for new contributors: [Yes, likely]
                Affects Version/s:     (was: 4.0.0.CR2)
                       Issue Type: New Feature  (was: Bug)

> Unlock at startup using SimpleFSLockFactory
> -------------------------------------------
>
>                 Key: HSEARCH-998
>                 URL: http://opensource.atlassian.com/projects/hibernate/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

        


More information about the hibernate-issues mailing list