-->
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: How to avoid thread deadlock?
PostPosted: Sun Feb 05, 2006 10:04 am 
Newbie

Joined: Thu Dec 22, 2005 11:15 pm
Posts: 13
Hi,

I am using Struts, Tomcat 5.1, hibernate 3.1.

Sometimes, my application runs slowly and message says:

Code:
17:36:43,250  WARN ThreadPoolAsynchronousRunner:429 -

com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@2b16

82 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!


Could anyone tell me how to avoid this?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 6:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Very hard question to answer and even harder on a forum. I really don't think this is a hibernate issue at all. It maybe a configuration of your database pooling library or they way your code works (,eg, are you spawning threads yourself?). Just not enough information to help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 12:50 am 
Newbie

Joined: Thu Dec 22, 2005 11:15 pm
Posts: 13
I didn't spawn any additional threads. And I use c3p0 as connection provider.

Hope someone could help.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 5:07 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try kill -3, it will print stack trace and all locks to stdout.


Top
 Profile  
 
 Post subject: I'm having the same problem
PostPosted: Wed Oct 11, 2006 5:35 am 
Newbie

Joined: Mon Jan 17, 2005 1:09 pm
Posts: 19
I'm having the problem, with the same configuration.
(apache-tomcat-5.5.16, hibernate 3.1.3, and the C3P0 version delivered with hibernate)

I changed from the tomcat database connection pool system to the C3P0 connection pool system.(because tomcat didn't seem to close the connections properly, causing the server to crash). Since I changed to C3P0 I also got the
Code:
APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
Error. Maybe the 2 problems are related, really no idea

with the mysql show status command, I see the following values increasing(I just restarted my server, so the values aren't that big yet);

mysql> show status
-> ;
+-----------------------------------+----------+
| Variable_name | Value |
+-----------------------------------+----------+
| Aborted_clients | 10 |
| Aborted_connects | 4 |


If anyone has any idea how to track down this problem.

executing 'SET GLOBAL thread_cache_size=8;' in mysql gave a hudge perfomace gain.
The mysql manual say the following about this variable.
Quote:
This variable can be increased to improve performance
if you have a lot of new connections. (Normally, this doesn't provide a notable performance
improvement if you have a good thread implementation.)

So I guesse I don't have a good thread implementation. I have no idea how to check this.

Any help would be welcome


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 8:11 pm 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Hi.

The "APPARENT DEADLOCK" messages are coming from c3p0's thread Pool. They occur when all threads in the pool are running tasks that seem "hung" for some period of time. The thread pool eventually recovers by interrupt()ing, discarding, and replacing the threads. But for a time, performance is impaired (and if the tasks don't respond to the interrupt, allowing the thread to terminate, the zombie threads might become permanently wasted memory).

The possibility of this sort of deadlock is impossible to eliminate entirely -- c3p0 has no way of ensuring that, say, attempts to close() a database Connection don't "hang". But there have been bugs in c3p0 that were probably responsible for the vast majority of these deadlocks. In particular, there were troublesome interactions between the statement cache and Connection close() operations. Many users could "fix" the problem by turning off c3p0 statement caching (in hibernate, hibernate.c3p0.max_statements=0), but this isn't a great solution for users hoping for performance gains from the statement cache.

I think that recent releases of the c3p0-0.9.1 series finally resolves the statement cache / Connection close() interaction deadlocks. And I know that c3p0-0.9.1 provides much better information if an APPARENT DEADLOCK should occur, for whatever reason.

I'd be grateful if users who see APPARENT DEADLOCK messages would download and try the latest version of c3p0 (c3p0-0.9.1-pre9), and let me know whether things have improved. (If they've not, please send me the full status, now logged with the APPARENT DEADLOCK message.)

Upgrading to a new c3p0 is as easy as downloading the latest version from sourceforge (http://sourceforge.net/projects/c3p0) and replacing the old c3p0-xxx.jar file in hibernate's lib directory with the latest jar from the binary distribution. (If you need to downgrade, just put the old jar file back.) Newer versions of c3p0 are much improved, c3p0-0.9.1 is pretty mature (I'm mostly waiting for feedback before calling 0.9.1 "official"), and switching versions is easy and nondisruptive. Please give it a shot, and let me know if you experience problems!

Steve <swaldman@mchange.com>

BTW, jdk1.5 users can get real-time info about c3p0 and its thread pool via jconsole; c3p0-0.9.1 installs a JMX MBean.


Top
 Profile  
 
 Post subject: Re: How to avoid thread deadlock?
PostPosted: Wed Jun 12, 2013 6:18 am 
Newbie

Joined: Mon Jun 10, 2013 2:51 am
Posts: 2
If you are a C3p0 developer please look at this post and let me know I have updated C3P0 jars from 0.9.1.2 to 0.9.2.1 and hibernate 3.2.6 GA to 3.6.10 final... However I am still getting the Apparant DeadLocks!!!

Please look at the post

https://forum.hibernate.org/search.php?search_id=egosearch


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.