WebSphere Issues


Connection leak diagnostics in WebSphere Application Server

Filed under: Java, WebSphere Application Server — Tags: , — Ishtiaque @ 12:29 pm

– Poorly written applications often do not properly release database connections.

  • Forget to call connection.close().
  • Most often in the exception case.
  • Connections should be closed in a finally{} block.

– Orphaned connections only return to the pool after timeout.

  • Can cause a backup of new connections waiting for old connections to time out.
  • New connections that have waited too long throw a connectionWaitTimeoutException.

– Connection manager is instrumented to print stack traces when a connectionWaitTimeoutException occurs.

  • Enabled using trace stringWAS.j2c=finest

Applications can suffer from performance problems and even appear to “hang” if they do not close their connections properly. This is most often caused by developers not properly using the connection.close() method. To ensure that connections will be closed properly, they should be closed in a finally{} block.

WebSphere is smart enough to eventually time out orphaned connections and return them to the pool, but for an application that makes frequent use of database connections, this might not be enough. New connections can get queued up waiting for the database while old connections are waiting to be timed out. This can bring the application grinding to a halt, and you can see connectionWaitExceptions.

The connection manager has lower performance impact than connection manager tracing. When activated, it enables a connection manager wrapper that holds the stack trace of all getConnection() calls in a throwable object. When an exception is thrown due to waiting on a full connection pool, print stack traces of all open connections. This enables you to significantly narrow your search area when you look at the application’s source code to try and find the responsible code.

Connection leaks have traditionally been hard to diagnose because the error messages do not usually provide specific enough information about the source of the problem. Usually a source code review is needed to find points in the code where connections are not properly closed. The connection manager makes this task much easier.



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: