-->
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.  [ 13 posts ] 
Author Message
 Post subject: WARNING: unclosed connection and autoClose
PostPosted: Wed Jan 28, 2004 6:34 pm 
Beginner
Beginner

Joined: Thu Jan 22, 2004 2:42 pm
Posts: 24
Hi, I have a project built around hibernate 2.0.1. Things were going well until we did a series of updates to our CVS repository that resulted in hibernate pitching a lot of "WARNING: unclosed connection" messages. These connections then gobble up all the available connections in the pool and lock up the system, I have to restart Tomcat. Has anyone out there experienced this? If so is there a simple explanation. I am trying to trigger the autoClose flag as an ad Hock solution, but I'd like to get to the root of why my connections are no longer closing through no change in my code.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 6:41 pm 
Regular
Regular

Joined: Fri Sep 05, 2003 12:01 am
Posts: 80
Location: Bogot
are you including your *.class into CVS control too?

Your source might say something. but your compiled classes could be different...

_________________
Mauricio Hern


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 6:47 pm 
Beginner
Beginner

Joined: Thu Jan 22, 2004 2:42 pm
Posts: 24
Our class files are not stored in the repository, we simply store the source code and rebuild it when we update. If there is no other explanation I would be willing to entertain that. But I think its unlikely, I think its far more likely that this is a configuration error of some kind.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 11:15 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 2:42 pm
Posts: 24
I have managed to trigger autoClose but that doesn't seem to solve anything. I'm close to running out of ideas at this point.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 5:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I am quite sure there was some change on your code or config in the process. Look for unclosed sessions or something like that.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 7:16 pm 
Beginner
Beginner

Joined: Thu Jan 22, 2004 2:42 pm
Posts: 24
We have looked for unclosed sessions and found them. This never happened before we did the merge and I think this kind of behavior puts the fault somewhere in the connection pooling. I have scoured the source for c3p0 and cannot find an explanation. I have placed breakpoints in the hibernate source near the sections that deal with open sessions and none of them are tripped. Yet I get messages about the sessions. this really doesn't make any sense to me. Moreover a google search reveals scant few other cases like this. So I am hoping someone here may know something about SessionImpl and how it could be producing this behavior.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 2:16 pm 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:34 pm
Posts: 36
Location: New York, NY
I am also having this problem, and I just switched to the c3p0 connection pool, was there ever a resolution? I believe I'm closing all sessions properly as well so I'm interested in anything you've found out.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 2:39 pm 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:34 pm
Posts: 36
Location: New York, NY
I've been doing some experimenting over here and it seems that although we have some "unclosed connection" warnings in our logs - when using the hibernate default pool, even set to a very low value, our server will not lock up. However, if we switch to the c3p0 pool then no matter how large we make the max connections, those connections will eventually be consumed and the application will lock.

So for now we're back on the default hibernate pool, but I'd be interested in hearing other's experiences.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 4:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I really, strongly recommend that you consider the fact that it is you application not closing sessions. Every single time anyone has ever had this problem, that was the cause.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 4:11 pm 
Beginner
Beginner

Joined: Thu Jan 22, 2004 2:42 pm
Posts: 24
I think it's a given that my application is no longer closing sessions. The problem is that I was closing my sessions appropriately before this configuration error occured. Now the connection pool doesn't close it's expired connections and I am trying to ascertain why. I switched to the apache connection pooling and while it is obvious the connections are left open, at least apache is closing and reclaiming them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 12:53 pm 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:34 pm
Posts: 36
Location: New York, NY
As an update, I've gone through my application and fixed all situations where the session might be closed by the finalizer, so I no longer get any warnings from hibernate, however the c3p0 problem is persisting.

However, I am not ruling out an Oracle specific problem here since when on the Hibernate default connection pool we see a number of lingering processes over the maximum number of connections I allow for the pool. In c3p0 we never go over the limit, but the server eventually locks up.


Top
 Profile  
 
 Post subject: c3p0 problems
PostPosted: Wed Feb 04, 2004 4:32 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi Matt!

Are you using Tomcat and c3p0?

Because I have had problems with the "reload" feature of Tomcat which obviously not ends c3p0's daemon threads but creates new ones without closing the old ones at each "reload" command. This always ends up with unexpected behaviour, possibly memory/resource leaks, and ClassNotFoundExceptions...

Sincerely,

/F


Top
 Profile  
 
 Post subject: Re: c3p0 problems
PostPosted: Wed Feb 04, 2004 5:17 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
kantorn wrote:
Hi Matt!

Are you using Tomcat and c3p0?

Because I have had problems with the "reload" feature of Tomcat which obviously not ends c3p0's daemon threads but creates new ones without closing the old ones at each "reload" command. This always ends up with unexpected behaviour, possibly memory/resource leaks, and ClassNotFoundExceptions...

Sincerely,

/F


I think you need to close session factory in context listener to solve this problem and do not forget to close session at the end of request, the most simple way is to close thread local session in filter.
Refactor app if you have code dublication in resource management, it must be trivial to remove "session.close()" and to move it to filter.
Test it with pooled connections and with plain connections, both ways must work if resource management is not broken.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.