日期:2014-05-16  浏览次数:20430 次

weblogic数据库连接池相关参数说明

比较容易混淆的参数解释

?

1:Inactive Connection Timeout

这个参数很重要,是10以后的版本新加的,9版本没有,一般情况建议不要开启该参数,即使开启也尽可能要把数值设置大些,比如1800秒等。这个字段的具体官方解释在10.3.0.0的版本如下,在XX系统中实际反映的情况是,如果该参数设置为30(即:30S)的话,在大并发下会出现weblogic认为的leaked的连接,而且这时weblogic就会强制关闭这些连接回收,导致后续的应用获取连接时报connection has alreadly been closed的异常,但如果把该参数禁用(设为0s),用同样的大并发测试则一切正常,当连接池连接都被用时,连接请求会等待,超时会报取不到连接的异常,这些都是正常连接池的表现,这时在monitor中也没有出现显示Leaked 的连接。所以猜测Inactive Connection Timeout参数如果开启的话应该会影响weblogic的Leaked连接数的判断方式,这个回头做下试验。。。

?

?

Automatically Recovering Leaked Connections

A leaked connection is a connection that was not properly returned to the connection pool in the data source. To automatically recover leaked connections, you can specify a value for Inactive Connection Timeout on the JDBC Data Source: Configuration: Connection Pool page in the Administration Console. When you set a value for Inactive Connection Timeout, WebLogic Server will forcibly return a connection to the data source when there is no activity on a reserved connection for the number of seconds that you specify. When set to?0(the default value), this feature is turned off.

See the?JDBC Data Source: Configuration: Connection Pool?page in the Administration Console or see “?JDBCConnectionPoolParamsBean” in the WebLogic Server MBean Reference for more details about this option.

Note that the actual timeout could exceed the configured value for Inactive Connection Timeout. The internal data source maintenance thread runs every 5 seconds. When it reaches the Inactive Connection Timeout (for example 30 seconds), it checks for inactive connections. To avoid timing out a connection that was reserved just before the current check or just after the previous check, the server gives an inactive connection a “second chance.” On the next check, if the connection is still inactive, the server times it out and forcibly returns it to the data source. On average, there could be a delay of 50% more than the configured value.

?

2:connection reserve timeout

注意这个参数不是连接从连接池里取出以后用来执行SQL等其它操作时的生命周期时间,而是当从连接池取连接时如果池里的连接目前都正在被使用且池里的连接数已经达到上限时,这个取连接动作的超时时间,在这个时间内会一直等着,超过这个时间就会报a Connection Unavailable SQL Exception,如果不设置这个时间,那么出现连接达到上限还要取连接时会立即报a Connection Unavailable SQL Exception。具体看下面官方文档的解释:

?

?

Enabling Connection Requests to Wait?for a Connection

JDBC data sources have two attributes that you can set to enable connection requests to wait for a connection from a data source: Connection Reserve Timeout (ConnectionReserveTimeoutSeconds) and Maximum Waiting for Connection (HighestNumWaiters). You use these two attributes together to enable connection requests to wait for a connection without disabling your system by blocking too many threads.

See the?JDBC Data Source: Configuration: Connection Pool?page in the