Saturday, July 4, 2015

"Inactive Connection Timeout" and "Remove Infected Connections Enabled" parameters in WebLogic Server

Have you ever wondered what the Inactive Connection Timeout and Remove Infected Connections Enabled settings do in Oracle WebLogic Server 11g/12c? They help address some of the issues your application may be experiencing as it pertains to data sources.

Accessing these parameters is done by simply navigating to Data Sources > [data source name] > Configuration > Connection Pool > Advanced.



Inactive Connection Timeout

Consider this parameter as a short term solution if you suspect your Java code having a connection leak. For example, a connection may be opened in the code but never closed. Usually you will see the number of 'Active Connections' increasing in the WebLogic Admin Console over time. Setting this parameter will force WebLogic Server to release the connection back to the connection pool after X seconds of inactivity.

The Oracle documentation states:
The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.
You can use the Inactive Connection Timeout feature to reclaim leaked connections - connections that were not explicitly closed by the application. Note that this feature is not intended to be used in place of properly closing connections.
When set to 0, the feature is disabled.
When this parameter is triggered, the following will appear in the logs:
####<Jul 1, 2015 8:30:47 AM EDT> <Warning> <JDBC> <soahost1> <soa_server1> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1435753847302> <BEA-001153> <Forcibly releasing inactive/harvested connection "[weblogic.jdbc.wrapper.JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection-SOADataSource-9054, oracle.jdbc.driver.LogicalConnection@1a72fd3f]" back into the data source connection pool "SOADataSource", currently reserved by: java.lang.Exception        at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:356)        at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:364)        at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:330)        at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:469)


Remove Infected Connections

Consider this parameter if you simply don't trust your application and/or are experiencing strange connection issues. When your Java application closes a connection, WebLogic Server will actually close it forcibly instead of releasing it back in the pool.

The Oracle documentation states:
Specifies whether a connection will be removed from the connection pool after the application uses the underlying vendor connection object.
If you disable removing infected connections, you must make sure that the database connection is suitable for reuse by other applications.
When set to true (the default), the physical connection is not returned to the connection pool after the application closes the logical connection. Instead, the physical connection is closed and recreated.
When set to false, when the application closes the logical connection, the physical connection is returned to the connection pool and can be reused by the application or by another application.
When this parameter is triggered, the following will appear in the logs:
java.sql.SQLException: Connection closed        at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:213)        at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:84)        at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:74)        at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:100)


Applicable Versions:
  • Oracle WebLogic Server 11g/12c


3 comments:

Kalyan N said...

Hello i have seen the posting..it is good.Here i need some clarification.
SO What you will advise me for this "Inactive Connection timeout value" is it true(some value) or False(0).What will you recomended for me..
Our JAVA EE application is Not Perfectly Tuned.
suppose i have gave true (some value of sec's) for the above & IF The Inactive Connections are closed? (they can't back again) is it difficult to re create for the connection pool ? How far it is difficult.? Which option is More Preferable in case of Less Tuned Application.Please Reply me to "nlkalyan.434@gmail.com" i am waiting for your input.

Ahmed Aboulnaga said...

Instead of setting the Inactive Connection Timeout, fix your Java code to ensure that all connections are properly closed. This is the recommendation.

But if you have no control over the Java code, then consider a value of 240, 120, or 60. You may want to use the shorter values of you have a very active environment.

If I understand your question correctly, if a connection is killed because of the Inactive Connection Timeout, then a new connection will automatically be created by the connection pool. No other action is required by you.

I'm not sure if I answered your question.

Kalyan N said...

hello , Thanks for reply... My clarification is .
Case -1 :: Let the Timeout = 10 :
AFTER 10 sec of In activeness of connections - they will close - SUSPENDED from the Connection POOL right. SO bringing them it connection pool is difficult ? (As per Performance i am speaking)
&
Case -2 :: Timeout = 0 : (default)
In this case the connections have n;t Closed and if closed anyway - They will back to Connection POOL of Database ...
SO in both cases .. which one is Better regarding Performance ( IN case of Less & Little Unstable JAVA EE Application )