-->
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: HS : Mass Indexer + C3PO
PostPosted: Mon Oct 17, 2011 10:57 am 
Regular
Regular

Joined: Thu Oct 08, 2009 10:34 am
Posts: 55
Hi Guys,

I believe im experiencing deadlock with my mass indexer. Recently we have changed our mass indexer config to see if we can increase our throughput time in finishing indexing quicker. This has had a side effect in which our app hangs.

We currently have 8 classes which are indexed. (So 8 indexes in total). Our mass indexer config is as follows

batch.indexer.batch.size=100
batch.indexer.fetch.threads=5
batch.indexer.load.objects=2

When configured like this, the indexer never gets started.......i see no log outputs. A thread dump reveals the following to me
I have
40 threads of type "Hibernate Search: collectionsloader-4" - Of which 23 are looking for a DB connection (5 * 8 = 40)
16 threads of type "Hibernate Search: entityloader-2" Of which 12 are looking for a DB connection. (8 * 2 = 16)
8 threads of type "Hibernate Search: identifierloader-1" - All 8 are awaiting a connection

All the above threads are stuck waiting for "awaitAvailable" to retrieve a connection.

Quote:
"Hibernate Search: identifierloader-1" prio=10 tid=0x000000004ff28000 nid=0xe44 in Object.wait() [0x0000000048360000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1315)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
- locked <0x00000000bed85908> (a com.mchange.v2.resourcepool.BasicResourcePool)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:78)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.StatelessSessionImpl.beginTransaction(StatelessSessionImpl.java:480)


So i have 43 threads all waiting for a DB connection!!

My c3po config is standard enough

Quote:
#connection pooling props
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.idle_test_period=100
hibernate.c3p0.max_size=20
hibernate.c3p0.max_statements=20
hibernate.c3p0.min_size=5
hibernate.c3p0.timeout=1000


When i seen this my first reaction is deadlock.......when i dont use such a high "fetch" and "load" config i dont see this issue. Have you guys a test case for running the mass indexer when the number of threads looking for connections exceeds the pool size??

Also came across this in my searching for a solution
https://jira.atlassian.com/browse/BAM-5670 different product i know but the symptoms are similar to what im experiencing.

Any thoughts on this??

LL


Top
 Profile  
 
 Post subject: Re: HS : Mass Indexer + C3PO
PostPosted: Wed Oct 19, 2011 4:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

hard to say where the problem is. Here are some tips which maybe help you to narrow down the problem.
Have you turned on debug/trace level logging? If so, is there anything in the logs? Which database are you using and are there any limits on how many connections it accepts? Have you tried switching to dbcp for example to see whether there is a problem with cp3o?

--Hardy


Top
 Profile  
 
 Post subject: Re: HS : Mass Indexer + C3PO
PostPosted: Wed Oct 19, 2011 5:47 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Have you guys a test case for running the mass indexer when the number of threads looking for connections exceeds the pool size??

No we don't have one; if you could create one that would be awesome as we have HSEARCH-598 : I'd be glad to look into the issue but have not had time to create a test for it.

The math you did is correct:
Quote:
So i have 43 threads all waiting for a DB connection!!

Quote:
hibernate.c3p0.max_size=20

So that's not going to work as unfortunately with the current pipeline design it needs all components of the pipeline "alive" to be able to start. My problem in changing the pipeline design is that this one is the only one which is really fast ;)

So when you're in this situation you have two possible workarounds:
1) use the other indexing method using the scrollable results
2) Instead of using the MassIndexer on all objects, use it on each entity once:

Code:
fullTextSession.createIndexer().startAndWait();

becomes
Code:
fullTextSession.createIndexer( Dvd.class ).startAndWait();
fullTextSession.createIndexer( Customer.class ).startAndWait();
fullTextSession.createIndexer( Book.class ).startAndWait();

So you won't have 43 threads started at the same time, but "only" 7 per type, which is below the 20 threshold.

Unfortunately there's no way to predict from the datasource what is the maximum amount of connection that I'm allowed to ask for, so I don't think we can log a warning about this but we might want to introduce a monitoring thread to check for deadlocks - but even so this would likely need to abort the process.

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


Top
 Profile  
 
 Post subject: Re: HS : Mass Indexer + C3PO
PostPosted: Thu Oct 20, 2011 5:37 am 
Regular
Regular

Joined: Thu Oct 08, 2009 10:34 am
Posts: 55
Thanks for the info Sanne.

Quote:
So when you're in this situation you have two possible workarounds:
1) use the other indexing method using the scrollable results
2) Instead of using the MassIndexer on all objects, use it on each entity once:

Option 1 would possibly be too slow.

Option 2 is a better option. Need to see how this performs.

Interesting read https://hibernate.onjira.com/browse/HSEARCH-598

Whats not clear to me from the thread is does HS leak threads over time?? So if i in theory kept my pool size greater than the need that HS needs, would this over time deadlock??

So example, lets say i configure my mass indexer like so
batch.indexer.batch.size=100
batch.indexer.fetch.threads=2
batch.indexer.load.objects=2

If have 8 indexes and if the math is right
collectionsloader - 2 * 8 = 16
entityloader - 2 * 8 = 16
identifierloader - 1 * 8 = 8

So a possible need of 40 connections at any given time. Now if i set my pool size to 45 with the above config and no other threads use the connection pool, would i run into deadlock over a period time?? (So thats with indexing everything in parallel) Ive cheated with my test environment, the above config works for me but im just worried that over a period of time i will get deadlock. I will do option 2 but for now, would i run into this deadlock issue over a period of time with the above config??


Cheers,
JB


Top
 Profile  
 
 Post subject: Re: HS : Mass Indexer + C3PO
PostPosted: Thu Oct 20, 2011 6:00 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Whats not clear to me from the thread is does HS leak threads over time?

No I'm not aware of it leaking threads, nor have I seen anything which would make me think that's possible.

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


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.