Sapien Blogs
Know the Unknown
Blog Home
«
Cloud Scalability &...
|
Main
|
JEE- Architecture...
»
No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))
You might have seen this error when working with jdbc datasource deployed on JBoss. This error is raised when free connections are not available in the connection pool for a new request. This happens due to a combination of factors.
Jboss pool size configuration
Low MaxSize setting in ManagedConnectionPool configuration
Database connection size
When not enough connections are accepted by the database.
Peak in requests
Typically, connection pool is tuned to handle various patterns of load. However, any unexpected surge in load/requests can deplete connections in the pool.
Long running transactions
They can hold a connection for a long time not making it available for waiting requests, and those waiting requests may eventually timeout.
Connections Leak
Connections are not closed/returned properly by the application, and those connections linger on eating up the whole pool. This can also happen if the application closes the connection directly without returning it to the pool. In fact, the connection given to the application by the pool is a wrapper of actual JDBC connection. Attempting to close the wrapper connection does not close the underlying JDBC connection but rather returns the connection to the pool. However, this is pool vendor dependent. See documentation.
Short blocking-timeout-millis
This pool configuration in JBOSS specifies the maximum time in milliseconds a worker thread block, while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time.
There are many ways to trouble shoot this error. First step is to understand if this is caused by a leak. Connection leak will eventually toast your server. But if this exception is caused by other means like pool size setting or surge in requests, the server would continue to serve few requests, which can be met by the available connections.
Your can troubleshoot this error through JMX Console- http://host:port/jmx-console. JMX console reports various metrics of jboss mbeans. For connection pool, look for ManagedConnectionPool mbean under JBoss.JCA category.
Logs are the most crucial help. Turn on jboss connection pool and hibernate jdbc logging, In jboss-log4j.xml, add-
<appender name="JDBC">
<errorHandler />
<param name="File" value="${jboss.server.log.dir}/jdbc.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="5000KB" />
<param name="Threshold" value="DEBUG" />
<layout>
<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
</layout>
</appender>
<category additivity="true" name="org.hibernate.jdbc">
<priority value="DEBUG" />
<appender-ref ref="JDBC" />
</category>
<category additivity="true" name="org.jboss.resource.adapter.jdbc">
<priority value="DEBUG" />
<appender-ref ref="JDBC" />
</category>
<category additivity="true"
name="org.jboss.resource.connectionmanager">
<priority value="DEBUG" />
<appender-ref ref="JDBC" />
</category>
References
http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch7.chapt.html
Sapien in
Java
02:01PM Oct 14, 2012
Comments[0]
Tags:
jboss
connection-pool
jdbc
Comments:
Post a Comment:
Comments are closed for this entry.
Bookmarks
Bookmark it
Digg it
Slashdot it
See who links to it
Related entries
HashMap vs ConcurrentHashMap vs Synchronized HashMap vs Hashtable
Java Performance: Collections
Java Performance: Synchronization and Parallel Processing
Java Performance: Memory and Garbage Collection
JEE- Architecture Layers
No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))
Cloud Scalability & Performance- Blog Digest
No servlet class has been specified for servlet template & metadata-complete
Scalability & Performance
Unable to marshall due to missing @XmlRootElement annotation
Reusing JDBC PreparedStatement
Polymorphism and Double Dispatch
Treasure the Memcache
Optimistic/Pessimistic Locking In Java