tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "tc" ...@summerhost.net>
Subject Re: Tomcat App becomes Unresponsive
Date Tue, 22 Jan 2008 01:22:51 GMT
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tc,
>
> tc wrote:
> | The developers think there may some issue with the database.  They have
> | also done multi-user testing without being able to reproduce the
> problem.
>
> If they think it's the database, it's probably their code interacting
> with the database. MySQL is pretty stable, although I have had some
> legitimate problems with it in the past.
>
> The most likely problem is that you have code that is not properly
> cleaning up after JDBC calls.
>
> Are you using a connection pool? If so, which one?
>
> You need to make sure that you call "close" on /everything/ when you're
> done with your Connection, Statement (and subclass), and ResultSet (and
> subclass) objects. Check to make sure that those close calls are done in
> "finally" blocks, and that a failure to close a ResultSet does not cause
> an exception to be thrown that avoids the Connection close.
>
> For example:
>
> Connection conn = getConnection();
>
> PreparedStatement ps = conn.prepareStatement("SELECT 1");
>
> ResultSet rs = ps.executeQuery();
>
> ...
>
> rs.close();
> ps.close();
> conn.close();
>
> return null;
>
> This is not good. What you really need is this:
>
> Connection conn = null;
> PreparedStatement ps = null;
> ResultSet rs = null;
>
> try
> {
> ~    conn = getConnection();
> ~    ps = ...;
> ~    rs = ...;
>
> ~    ...
> }
> finally
> {
> ~    if(null != rs)
> ~        try { rs.close(); } catch (SQLException sqle) { /* log */ }
> ~    if(null != ps)
> ~        try { ps.close(); } catch (SQLException sqle) { /* log */ }
> ~    if(null != conn)
> ~        try { conn.close(); } catch (SQLException sqle) { /* log */ }
> }
>
> Note how all the cleanup is done in the finally block (so the cleanup
> code will run even during an exception situation), and that each "close"
> is called in its own try/catch block: this prevents the failure to close
> the (e.g.) ResultSet from preventing the Statement or Connection from
> closing. Remember to log anything weird.
>
> | I'm looking for pointers to any resources on the web or elsewhere that
> can
> | help me track down the problem, or ideas about where to look, or what we
> | can do to improve post-freeze diagnosis of this problem.
>
> When the app freezes, what are yout threads doing? Does the server stop
> serving requests entirely, or do some of them work while others do not?
>
> Good luck,
> - -chris


Thanks for the suggestions.  I will have a look at the source and see how 
the app is interacting with the database.

I don't think the whole tomcat server freezes; just the one application.

I'm not sure how to know what my threads are doing.






---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message