Hello,
I have a web application that runs on two non-clustered nodes (with a load-balancer in front of it). Now my main problem is that once I update an entity the search index needs to get updated on both nodes. I tried to do it over infinispan with and without jgroups-master-slave. The only configuration that is working is, when I manually assign master and slave. But this is not an option for me, in our environment the ear is auto-deployed on both nodes, so there can be no difference.
With jgroups set to auto
Code:
<property name="hibernate.search.default.worker.backend" value="jgroups"/>)
and even without jgroups at all with only
Code:
<property name="hibernate.search.default.directory_provider" value="infinispan"/>
I always get a Lock-Exception:
Work Type org.hibernate.search.backend.UpdateLuceneWork
: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: org.infinispan.lucene.locking.BaseLuceneLock@23e2066b
at org.apache.lucene.store.Lock.obtain(Lock.java:84) [lucene-core-3.6.2.jar:3.6.2 1423725 - rmuir - 2012-12-18 19:45:40]
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1098) [lucene-core-3.6.2.jar:3.6.2 1423725 - rmuir - 2012-12-18 19:45:40]
at org.hibernate.search.backend.impl.lucene.IndexWriterHolder.createNewIndexWriter(IndexWriterHolder.java:146) [hibernate-search-engine-4.4.2.Final.jar:4.4.2.Final]
at org.hibernate.search.backend.impl.lucene.IndexWriterHolder.getIndexWriter(IndexWriterHolder.java:113) [hibernate-search-engine-4.4.2.Final.jar:4.4.2.Final]
at org.hibernate.search.backend.impl.lucene.AbstractWorkspaceImpl.getIndexWriter(AbstractWorkspaceImpl.java:117) [hibernate-search-engine-4.4.2.Final.jar:4.4.2.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.applyUpdates(LuceneBackendQueueTask.java:101) [hibernate-search-engine-4.4.2.Final.jar:4.4.2.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.run(LuceneBackendQueueTask.java:67) [hibernate-search-engine-4.4.2.Final.jar:4.4.2.Final]
It is also not working with
Code:
<property name="hibernate.search.default.exclusive_index_use" value="false"/>
or
Code:
<property name="hibernate.search.default.locking_strategy" value="none"/>
I think it's because of an error in AutoNodeSelector: If there is only one node, it selects the first node, if the second node comes up it selects the second node without releasing the first node's lock on the index, I guess.
It is working, if I do the following:
Deploy on node 1
Now node 1 is master and has the lock
deploy on node 2
now node 2 is master but gets exception on updates of entities
redeploy on node 1
now node 1 is master again, it all works fine
But of course this is not possible in production. ;-)
So here are some ideas:
It should be possible to have a non shared ram-index on each node, with jgroups to tell all nodes to update their index so you won't have any locking problems. This solution would work without any infinispan clustering.
It should be possible to overide AutoNodeSelector or define NodeSelection programmtically
Do you have any other ideas on how to solve it?