-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate Search - deadlocks
PostPosted: Wed Apr 30, 2008 6:12 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
Hi,

I have a very weird issue with hibernate search (latest version with lucene 2.3.1). I have a RESTful web interface that exposes search capabilities. Some of them are using lucene.

I have performed load testing on this interface and the figures are good when running on a pure Lucene query (50 msec for 1 concurrent user, 150msec for 10 concurrent users)

Now, If I combine a lucene search and a database search (hybrid query), it takes 300msec for 1 user and 3sec for 10 users. When I run the profiler on the server, I see deadlocks on org.apache.lucene.index.SegmentReader.

Switching to "non-shared" index reader reduces those deadlocks but it's still very slow with 10 concurrent users (2.8sec).

The hybrid query does the following:

* Run a query on the lucene index
* Run a query on the database with some criterion
* Intersect the IDs that match
* Return the matches using select a from MyClass a where ID in (2,4,6,7...)

The result is limited to 20 results in my test.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 01, 2008 4:07 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
Quote:
The result is limited to 20 results in my test.

Do you mean the combined result, or are you limiting both lucene's index results and database results?

Quote:
MyClass a where ID in (2,4,6,7...)

The complexity of such a query could grow without control and is not recommended...
use it only if you are sure that both sub-results are very limited.

I explained a better approach to this type of search here:
http://forum.hibernate.org/viewtopic.php?t=986180

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 01, 2008 4:52 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
s.grinovero wrote:
Hi,
Quote:
The result is limited to 20 results in my test.

Do you mean the combined result, or are you limiting both lucene's index results and database results?

Quote:
MyClass a where ID in (2,4,6,7...)

The complexity of such a query could grow without control and is not recommended...
use it only if you are sure that both sub-results are very limited.

I explained a better approach to this type of search here:
http://forum.hibernate.org/viewtopic.php?t=986180


Yes I know, I am the one who asked the question :)

The combine result is limited. The lucene search and the database search are not (and that's most probably the problem)

So I use a ScrollableResultset and I fetch only the primary key from the database. I am wondering though what you mean by "adding them all to a set". This solution may consume a lot of memory no?

Can you maybe explain in more details the algorithm?

Any idea regarding the deadlock on SegmentReader?

Thx,
Stéphane


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 11:46 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
So I am back with this problem. I have investigated the problem the whole day.

I have written my test in a simple java class that uses only the lucene API. This test has one IndexSearcher instance that 10 threads share. The 10 threads perform the exact same lucene query as the one I'm doing in hibernate search.

Result: 100 msec on average per client with 10 concurrent clients

With Hibernate search:

- Around 2 sec with the default reader strategy (lots of deadlocks on SegmentReader in this case)
- Around 1 sec with reader strategy as not shared

I tried to upgrade my code to use the lucene API directly as described in http://www.hibernate.org/hib_docs/searc ... ative.html

but it's still dead slow.

Does anyone has an idea of what could be wrong? If I don't find the solution, I wll simply rebuild a lucene service and use hibernate search only for indexing.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 11, 2008 11:22 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I'm interested: the performance should be similar between Search and Lucene, either you have some configuration error or you found some bug.

Quote:
Around 2 sec with the default reader strategy (lots of deadlocks on SegmentReader in this case)
- Around 1 sec with reader strategy as not shared

Are you sure you are using the Shared strategy? This is default now, but early versions of Hibernate Search did use the No-Shared strategy.

http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-106

Which version of Search are you using?
Could you verify that you really are getting an instance of the Shared Reader?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 6:15 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
s.grinovero wrote:
Hi,
I'm interested: the performance should be similar between Search and Lucene, either you have some configuration error or you found some bug.

Quote:
Around 2 sec with the default reader strategy (lots of deadlocks on SegmentReader in this case)
- Around 1 sec with reader strategy as not shared

Are you sure you are using the Shared strategy? This is default now, but early versions of Hibernate Search did use the No-Shared strategy.

http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-106

Which version of Search are you using?
Could you verify that you really are getting an instance of the Shared Reader?


I am using HS 3.0.1 GA and yes I have a shared reader. If I use a non-shared reader I don't have the deadlocks anymore but I think it's related to the fact that I am browsing a lot of results in the index tree. I can reproduce this with pure lucene calls now. I've asked on the lucene user list the best way to retrieve a lot of results from a query without locking the underlying resources.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The problem has been investigated and mostly explained. check here

http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-194

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.