WAS ConnectionWaitTimeoutExceptions
WAS ConnectionWaitTimeoutExceptions
Agenda
Problem Symptoms
Several problem symptoms may occur:
1. J2CA0045E error
J2CA0045E: Connection not available while invoking method
createOrWaitForConnection for resource jdbc/db2demo.
2. ConnectionWaitTimeoutException
com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException:
Connection not available, Timed out waiting for 180004
3. Slow performance
Application running slower than expected, and transaction
timeouts (WTRN0006W) could occur
4. Threads “hung” waiting for free connection...
What is a LTC?
LTC is Local Transaction Containment, started every time a servlet
is invoked, or EJB without container-managed transactions
Started in the absence of a global transaction
Contains one or more Resource Manager Local Transactions
(RMLTs)
LTC is not controlled by the application
Shareable connections will not return to free pool until LTC ends
Remain allocated for possible reuse within the LTC
LTC ends when servlet service method or EJB method exits
Long-running LTCs can cause connections to be held too long
Connections are automatically closed when the LTC ends
No free connections
• Resource References
− Res-sharing-scope: Unshareable
Connection Pool Custom Property:
• globalConnectionTypeOverride = unshared
− Will override all other settings, including resource references
• defaultConnectionTypeOverride = unshared
− Will provide the default if none specified on resource reference
No free connections
try {
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup("jdbc/db2demo");
conn = ds.getConnection();
while(rs.next())
out.println(rs.getString(1));
rs.close();
pStmt.close();
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
rs.close();
pStmt.close();
conn.close();
}
No free connections
No free connections
General Suggestions
If the problem cannot be reproduced and data cannot be collected,
follow these general guidelines to reduce likelihood of Connection
Wait Timeouts
Test with higher values for Maximum Connections
Ensure that Maximum Connections is equal to or greater than
maximum web container and/or ORB thread pool sizes
Check application for connection leaks, especially cases where
there is no finally block to close connections
Ensure that application follows get – use – close pattern
Switch from shareable to unshareable connections if
application does not use global transactions
Summary
Overview of Connection Wait Timeouts
Problem Symptoms
Data Collection
Data Analysis
Five common root causes
• Use of Shareable Connections in Long-Running LTC
• Multiple connection requests on same thread without
calling close()
• Connection leak in application
• Long-running queries or slow database response time
• Maximum Connections set too low
How to resolve problem for each root cause
Questions and Answers
Additional Resources
Technical Exchange: "Understanding J2C Connection Pooling in
WebSphere Application Server"
http://www.ibm.com/support/docview.wss?uid=swg27039167
Technical Exchange: "Response Time Analysis for Databases and Web
Services in WebSphere Application Server"
http://www.ibm.com/support/docview.wss?uid=swg27016472
MustGather: Connection pooling problems for WebSphere Application
Server
http://www.ibm.com/support/docview.wss?uid=swg21254645
Technote: "How to troubleshoot J2CA0045E connection pooling problems"
http://www.ibm.com/support/docview.wss?uid=swg21385033
Education Assistant: "Connection pool tuning and management problems"
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.was_v7/was/7.0/ProblemDetermination/WA5721G10_ConnectionPool_edited/player.html
View a webcast replay with step-by-step instructions for using the Service Request (SR)
tool for submitting problems electronically:
http://www.ibm.com/software/websphere/support/d2w.html
Sign up to receive weekly technical My Notifications emails:
http://www.ibm.com/software/support/einfo.html
3. Be connected!
Connect with us on Facebook
Connect with us on Twitter