0
votes

I have an

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/XXXXX/User_Index/write.lock

exception and I read that the write timeout lock should be increased from the default 1 second.

(
It is interesting that previously I didn't have this exception but I work on a task to use Spring on the project. There is a small chance that there are more, competing transactions trying to get access to the index...? I don't think I think the Spring transaction is configured properly:

<!-- for the @Transactional annotations -->
<tx:annotation-driven />
<context:component-scan base-package="XXX.audit, XXX.authorization, XXX.policy, XXX.printing, XXX.provisioning, XXX.service.plainspring" />
<!-- defining Transaction Manager for Spring -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="dataSource" ref="dataSource" />
    <property name="sessionFactory" ref="sessionFactory" />
</bean> 

)

So I tried to configure the write lock timeout like

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" lazy-init="true">
    ...
    <property name="hibernateProperties">
        <props>
            ...
            <prop key="hibernate.search.lucene_version">LUCENE_35</prop>
            <prop key="hibernate.search.default.indexwriter.writeLockTimeout">20000</prop>
            ...
    </property>
    <property name="dataSource">
        <ref bean="dataSource"/>
    </property>
</bean>

but no success. Apache Lucene doesn't have config file. Also there is no Lucene code, only Hibernate Search is used (i.e. not possible to set the value of an IndexWriter)

How can I configure the the write lock timeout?

Apache Lucene 3.5 Hibernate Search 4.1.1

Thanks,
V.

1

1 Answers

2
votes

There is no option to configure the IndexWriter lock timeout, as this should never be needed.

If you see such a timeout happening it's usually because of either of:

  • There is a lock file in the index directory as a left over from a crashed JVM
  • The configuration isn't suitable for the architecture of the application

Check the left over scenario first: shut down your application and see if there is a file name write.lock. If the application is not running it's safe to delete this file.

If that's not the case then you probably have two different instances of Hibernate Search attempting to use the same index directory, and both attempting to write to it. That's not a valid configuration and you're getting the exception because the index is already locked by te other instance; having a lock timeout increase would only have you wait for a very long time - possibly until the other application is shut down.

Don't share indexes among applications; if you really need to do so, check the manual for the JMS based backends or other non-default backends which allow for multiple applications to share a single IndexWriter.

Finally, please consider upgrading. These versions are extremely old.