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.  [ 4 posts ] 
Author Message
 Post subject: Dead Lock: Isolater starves Connection Pool
PostPosted: Wed Apr 26, 2006 8:22 am 
Beginner
Beginner

Joined: Thu Feb 16, 2006 9:53 am
Posts: 24
Hi all,

I guess I found a major bug, but I request your opinion before report it in Jira. By the way any workaround are welcome.

So, here is the bug.

Test Case:
I use a TableHiloGenerator to generate uid for an object (e.g Event).
The max_lo value is set to a small value (e.g 1024).

The max connection number of my pool is set to 10 per example.

Now if I persist more than 10x1024 new Events, a dead lock occurs.

Explanation:
The TableHiloGenerator use the Isolater class to increment the counter in a dedicated transaction. To do so a connection is retrieved from the pool, but never released!
After a while, the pool is empty and the max connection number is reached. So the next session or Isolater execution will wait indefinitely for a free connection.

This issue is not limited to our test case. This dead lock may occur after a while if a large number of objects are created.

Code & Fix:
Check the inner class org.hibernate.engine.transaction.Isolater.JdbcDelegate, line 191.
A curly bracket is at the wrong place.
lines 191 and 192 must be switched round.

Impacts:
Major, Connection Management is a key point of any application.

Hibernate version: 3.1.3

Thread Dump

"Thread-64" daemon prio=5 tid=0x00bca0e8 nid=0x7a in Object.wait() [acdfe000..acdffc28]
at java.lang.Object.wait(Native Method)
- waiting on <0xcbf98020> (a com.mchange.v2.resourcepool.BasicResourcePool)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:966)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
- locked <0xcbf98020> (a com.mchange.v2.resourcepool.BasicResourcePool)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:232)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:495)
at org.hibernate.engine.transaction.Isolater$JdbcDelegate.delegateWork(Isolater.java:147)
at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:38)
at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:51)
at org.hibernate.id.MultipleHiLoPerTableGenerator.generate(MultipleHiLoPerTableGenerator.java:183)
- locked <0xcc026d68> (a org.hibernate.id.MultipleHiLoPerTableGenerator)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:494)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 11:05 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Hi alexism - I think that's a known issue: http://opensource.atlassian.com/project ... se/HB-1246


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 12:05 pm 
Beginner
Beginner

Joined: Thu Feb 16, 2006 9:53 am
Posts: 24
Thanks for the link R1ch,

but I think my issue is not exactly the same.
I point out a non-release connection issue not a "out of connection" pb.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:29 am 
Beginner
Beginner

Joined: Thu Feb 16, 2006 9:53 am
Posts: 24
I can confirm this is a real "not release connection" bug.
I set up c3p0 with a timeout of 5mn, I create a lot of a new objects with a small max_lo value.
37 connections has been check out from the pool, but 12 hours later they are still not released!

But it is already reported in jira: HHH-1669


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