X

Proactive insights, news and tips from Oracle WebLogic Server Support. Learn Oracle from Oracle.

  • November 4, 2015

Connection Leak Profiling for WLS 12.2.1 Datasource

Stephen Felts
Manager

This is the first of a series of three articles that describes
enhancements to datasource profiling in WLS 12.2.1. These enhancements were requested by customers and Oracle support. I think they will be very useful in tracking
down problems in the application.

The pre-12.2.1 connection leak diagnostic profiling option
requires that the connection pool “Inactive Connection Timeout Seconds”
attribute be set to a positive value in order to determine how long before an
idle reserved connection is considered leaked. Once identified as being leaked, a connection is reclaimed and
information about the reserving thread is written out to the diagnostics
log. For applications that hold
connections for long periods of time, false positives can result in application
errors that complicate debugging. To
address this concern and improve usability, two enhancements to connection leak
profiling are available:

1. Connection leak
profile records will be produced for all reserved connections when the
connection pool reaches max capacity and a reserve request results in a
PoolLimitSQLException error.

2. An optional
Connection Leak Timeout Seconds attribute will be added to the datasource
descriptor for use in determining when a connection is considered
“leaked”. When an idle connection
exceeds the timeout value a leak profile log message is written and the
connection is left intact.

The existing connection leak profiling value (0x000004) must
be set on the datasource connection pool ProfileType attribute bitmask to
enable connection leak detection. Setting the ProfileConnectionLeakTimeoutSeconds attribute may be used in
place of InactiveConnectionTimeoutSeconds for identifying potential connection
leaks.

This is a WLST script to set the values.

# java weblogic.WLST prof.py

import sys, socket, os

hostname = socket.gethostname()

datasource='ds'

svr='myserver'

connect("weblogic","welcome1","t3://"+hostname+":7001")

# Edit the configuration to set the leak timeout

edit()

startEdit()

cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource +
'/JDBCConnectionPoolParams/' +
datasource )

cmo.setProfileConnectionLeakTimeoutSeconds(120) # set the connection leak
timeout

cmo.setProfileType(0x000004) # turn on profiling

save()

activate()

exit()

This is what the console page looks like after it is set.  Note the profile type and timeout value are set on the Diagnostics tab for the datasource.

The existing leak detection diagnostic profiling log record
format is used for leaks triggered by either the ProfileConnectionLeakTimeoutSeconds
attribute or when pool capacity is exceeded. In either case a log record is generated only once for each reserved
connection. If a connection is
subsequently released to pool, re-reserved and leaked again, a new record will
be generated. An example resource leak diagnostic
log record is shown below.  The output can be reviewed in the console or by looking at the datasource profile output text file.

####<mydatasource>
<WEBLOGIC.JDBC.CONN.LEAK> <Thu Apr 09 14:00:22 EDT 2015>
<java.lang.Exception
at
weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:398)
at
weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:365)
at
weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:331)
at
weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:568)
at
weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:498)
at
weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:135)
at
weblogic.jdbc.common.internal.RmiDataSource.getPoolConnection(RmiDataSource.java:522)
at
weblogic.jdbc.common.internal.RmiDataSource.getConnectionInternal(RmiDataSource.java:615)
at
weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:566)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:559)
...

>
<autoCommit=true,enabled=true,isXA=false,isJTS=false,vendorID=100,connUsed=false,doInit=false,'null',destroyed=false,poolname=mydatasource,appname=null,moduleName=null,

connectTime=960,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1428602415037,secondsToTrustAnIdlePoolConnection=10,

currentUser=...,currentThread=Thread[[ACTIVE] ExecuteThread: '0' for queue:
'weblogic.kernel.Default (self-tuning)',5,Pooled
Threads],lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},

supportIsValid=true> <[partition-id: 0] [partition-name: DOMAIN] >

For applications that may have connection leaks but also have some valid long-running operations, you will now be able to scan through a list of connections that may be problems without interfering with normal application execution.

Join the discussion

Comments ( 2 )
  • Faisal Qadeer Friday, June 8, 2018
    Is setProfileConnectionLeakTimeoutSeconds is specific to Weblogic 12. That mbean property not working on 11g. I'm getting an error:

    Starting an edit session ...
    Started edit session, please be sure to save and activate your
    changes once you are done.
    Problem invoking WLST - Traceback (innermost last):
    File "enable_profile.py", line 14, in ?
    AttributeError: setProfileConnectionLeakTimeoutSeconds
  • Stephen Felts Wednesday, June 13, 2018
    As the title and text above indicate, this feature is first available in WLS 12.2.1. It is not available in earlier WLS releases.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services