From: Bertrand R. <ber...@mo...> - 2008-05-25 20:51:12
|
In one of your previous post you said: [...] The time between connection #91 and connection #171 is only 30 minutes (from 23-mag-2008 13.16.48 to 23-mag-2008 13.46.44). And I can't understand why there are so many connections open in only 30 minutes. Do you have some ideas about that? [...] So the question was: "why do I have so many connections being created" ? If I understand correctly, you seem to have many connections being created/closed in a short time - which is different from having many connections at the same time. In any case, having many connections being created so rapidly makes me believe you have a new connection for "nearly" every Hibernate statement, instead of having one for every HTTP requests to your application (spanning multiple Hibernate requests). In a typical web application, you often want to have a single transaction per http request - which leads to a so-called "application transaction". One way to implement this pattern is to have a kind of filter in front of your servlet handling the transaction for you - making sure every opened transaction is actually closed when the servlet completes. I would suggest you turn on Hibernate debug and look for the session creation/close events. This may give you some hints about what is going on... /bertrand _____ From: Luca Bertuccelli [mailto:lbe...@ho...] Sent: dimanche 25 mai 2008 22:23 To: 'Bertrand Renuart'; 'Bill Horsman'; pro...@li... Subject: R: [Proxool-user] R:R: warning in tomcat enviroment Hi Bertrand, I checked my code and I think that my Hibernate Sessions are always closed. If I watch the AdminServlet datas, the number of available connections are not gowing (I didn't see more than 5 availables connections). In your opinion, this fact can demostrate that all the connections are managed well? Luca _____ Da: Bertrand Renuart [mailto:ber...@mo...] Inviato: sabato 24 maggio 2008 13.33 A: 'Luca Bertuccelli'; 'Bill Horsman'; pro...@li... Oggetto: RE: [Proxool-user] R:R: warning in tomcat enviroment Hi Luca, Your problem is a typical "Hibernate" problem where your hibernate sessions are not properly closed. Can you tell us how your hibernate sessions and transactions are managed in your code ? Do you follow the "open session in view" pattern or something else ? /bertrand _____ From: pro...@li... [mailto:pro...@li...] On Behalf Of Luca Bertuccelli Sent: samedi 24 mai 2008 0:02 To: 'Bill Horsman'; pro...@li... Subject: [Proxool-user] R:R: warning in tomcat enviroment Hi Bill, Thank you for your replay. The time between connection #91 and connection #171 is only 30 minutes (from 23-mag-2008 13.16.48 to 23-mag-2008 13.46.44). And I can't understand why there are so many connections open in only 30 minutes. Do you have some ideas about that? Then the SQL in the log file is the following "select prefvisupo0_.idPrefVisuPortali as idPrefVi1_, prefvisupo0_.idPortale as idPortale10_, prefvisupo0_.idUser as idUser10_ from prefVisuPortali prefvisupo0_ where iduser=308;". So it is a easy select query and it is not possible that the time to execute it is more then 5 minutes. Luca _____ Da: pro...@li... [mailto:pro...@li...] Per conto di Bill Horsman Inviato: venerdì 23 maggio 2008 22.51 A: pro...@li... Oggetto: Re: [Proxool-user] warning in tomcat enviroment Hi Luca, On Fri, May 23, 2008 at 1:35 PM, Luca Bertuccelli <lbe...@ho...> wrote: Why are there so many connections to remove (more than the maximum-connection-count)? I can't tell from your log output how much time passed between connection #91 being closed and connection #182. I'm assuming that new connections are being created on demand during that time - that is why it has closed more than 30. Why has been the connection removed only after 325219 milliseconds? That's the default maximum-active-time, 5 minutes. The housekeeper runs every 30 seconds, by default, so in this case it was closed by the housekeeper after 5m 25s. The clue to the problem lies in the SQL that was being performed (which I think you snipped out for privacy reasons). Looking at that should tell you what part of your code is experiencing the problem. Or maybe it's all DB calls that are taking a long time, in which case it the problem might lie in the DB itself (or connectivity to it). Finally, unless you close your connection nicely, in a finally block, it could be that the DB call worked as planned but your code didn't close the connection. In which case, Proxool can't tell the difference between a connection that is busy and a connection that wasn't closed. The fact that it only happens after a month is going to make chasing this done tough. Good luck. Regards, -- Bill Horsman http://www.logicalcobwebs.com/bill_horsman |