-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Search thread safe?
PostPosted: Wed Jan 31, 2007 12:48 pm 
Newbie

Joined: Fri Dec 15, 2006 6:08 am
Posts: 18
Location: France
Hi,

I'm using Hibernate annotations with lucene in my application.
This simple program persists an entity then delete it just after.
The entity which is persisted is also indexed in a file using lucene.

Here is the code :
Code:
public void run() {
// create alarm
Alarm alarm = new Alarm();
alarm.setName("new");
Alarm created = service.create(alarm);

// get primary key of created alarm
Long pk = created.getOid();
            
// delete alarm
service.delete(pk);
}


Code:
@Entity
@Indexed(index="searchindexes")
public class Alarm {
    private String name;
    private Long oid;
    private Integer version;

    @Field(index=Index.TOKENIZED,store=Store.YES)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_STORE")
    @DocumentId
    public Long getOid() {
        return this.oid;
    }

    public void setOid(Long oid) {
        this.oid = oid;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
}


I would like to simulate several clients in my application, so I put this code in a Thread. Thus, all clients are executing their requests at the same time.
The problem is that if I execute my application with more than 3 threads, then I get the following exception :
Code:
java.io.IOException: IndexReader out of date and no longer valid for delete, undelete, or setNorm operations
   at org.apache.lucene.index.IndexReader.aquireWriteLock(IndexReader.java:499)
   at org.apache.lucene.index.IndexReader.deleteDocument(IndexReader.java:514)
   at org.hibernate.search.backend.impl.LuceneWorker.remove(LuceneWorker.java:100)


If I increase the number of threads to 15, I've also the following exception :
Code:
java.io.IOException: Lock obtain timed out: Lock@C:\DOCUME~1\user\LOCALS~1\Temp\lucene-1892baef65d90cfb4f1135a0920fae48-write.lock
   at org.apache.lucene.store.Lock.obtain(Lock.java:56)
   at org.apache.lucene.index.IndexReader.aquireWriteLock(IndexReader.java:489)
   at org.apache.lucene.index.IndexReader.deleteDocument(IndexReader.java:514)
   at org.hibernate.search.backend.impl.LuceneWorker.remove(LuceneWorker.java:100)


Bellow three simulated users, it works, but with four users or more, It fails!
So my question is : Is Hibernate Search thread safe?



Hibernate version: 3.2.2 GA
Hibernate Annotations: 3.2.1 GA
Name and version of the database you are using: Oracle 10


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 6:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It should be thread safe.
Can you post your test case to JIRA, I need to give it a try (I fixed some but in SVN in this area, but it would be safer to test).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 10:51 am 
Newbie

Joined: Fri Dec 15, 2006 6:08 am
Posts: 18
Location: France
Ok, I will post a test to jira as soon as possible.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 9:35 am 
Newbie

Joined: Fri Dec 15, 2006 6:08 am
Posts: 18
Location: France
The issue has disapeared with version 3.0.0.Beta1.
Thanks for the correction...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
cool

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.