IBM Support

J2CA0086W, LTCs, and Running Out of Shared Connections in WebSphere Application Server

Technical Blog Post


Abstract

J2CA0086W, LTCs, and Running Out of Shared Connections in WebSphere Application Server

Body

 

A common problem you may have run into is the dreaded running out of connections in your connection pools. This could cause a variety of issues but likely you will see general system slowness, especially for applications directly using the database.

A very good webcast replay from our popular WebSphere Support Technical Exchange covering the various reasons for full connection pools is located here: Understanding and Resolving ConnectionWaitTimeout Exceptions in WebSphere Application Server

This blog post will cover a bit more about Shareable Connections running in a Local Transaction Containment.

Shareable Connections are set to default in WebSphere Application Server. Shareable connections are actually only fully utilized if you carefully plan for them. Shareable connections are only truly reused when all of the following are true: Both connections are in the same JVM, use the same transaction manager, have identical properties, marked as shareable, and are both used within a container managed or bean managed transaction scope.

Even when all of those conditions are met, you may still not see any benefits of shared connections over unshared connection on systems that constantly keep connections open by using them. When using unshared connections that are available in the free pool they remain open to the database and new requests don't pay the penalty of opening a new physical connection.

There are several possible pitfalls to consider when using Shareable Connections:

  • Transactional behavior
    • WebSphere Application Server has a transactional concept called Local Transaction Containment (LTC). This is our answer to the unspecified transaction condition in the EJB specification when a transaction is not a Global Transaction. When you are using a shareable connection in a LTC you will see the following warning in your logs:

J2CA0086W: Shareable connection {0} from resource {1} was used within a local transaction containment boundary.

This warning is issued because even if you use the proper get -> use -> close pattern for your connections, the connections will stay in use and not be released into the free pool until that LTC completes. This can lead to the connection being in use for a long period of time. If you have several LTCs using shareable connections it can be enough to keep all connections in the pool in use resulting in J2CA0045E.

  • Servlets
    • Servlets use LTCs in WebSphere Application Server by default. If the servlet uses data source connections, those connections will remain in use and unusable by other applications until the doService() method ends.

There are two common methods to resolve J2CA0086W warnings:

  1. The easiest way to resolve J2CA0086Ws is the switch to unshareable connections. As mentioned previously, in most cases this will not result in a performance hit. We do encourage performance testing if there is doubt that unshareable is not performing as well as shareable in your environment. There are two ways to change to unshareable connections in WebSphere Application Server:

    1. Modify data source setting defaultConnectionTypeOverride as described in the product documentation: Tuning connection pools
    2. or Modify the resource reference of your application so that the Sharing Scope is Unshareable per this topic in the product documentation: Creating or changing a resource reference

  2. Enclose the connection portion into a UserTransaction which is part of the Java™ Transaction API. The transaction will begin as a LTC, but be suspended when the connection starts the Global Transaction. The connection will be released to the free pool when the Global Connection ends and the LTC continues. This method is generally not recommended over the use of unshareable connections as creating the UserTransaction can have a performance impact. We would generally only recommend trying this if the use of unshareable connections also effects performance.

 

 

title image (modified) credit: (cc) Some rights reserved by Nemo

 

[{"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Product":{"code":"","label":""},"Component":"","Platform":[{"code":"","label":""}],"Version":"","Edition":""}]

UID

ibm11080447