X

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

  • November 4, 2015

Local Transaction Leak Profiling for WLS 12.2.1 Datasource

Stephen Felts
Manager

This is the third of this series on profiling enhancements in WLS 12.2.1 (but maybe not the least since this appears to happen quite often). 

This is a common application error that is difficult to
diagnose when an application leaves a local transaction open on a connection
and it is returned to the connection pool. This error can manifest as XAException/XAER_PROTO errors, or as
unintentional local transaction commits or rollbacks of database updates. Current workarounds to internally
commit/rollback the local transaction when a connection is released adds
significant overhead, only masks errors that may be surfaced to the application,
and still leaves the possibility of data inconsistency.

The Oracle JDBC thin driver supports a proprietary method to
obtain the local transaction state of a connection. A new profiling option will be added that
will generate a log entry when a local transaction is detected on a connection
when it is released to the connection pool. The log record will include the call stack and details about the thread
releasing the connection.

To enable local transaction leak profiling, the datasource
connection pool ProfileType attribute bitmask must include the value
(0x000200).

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.setProfileType(0x000200) # turn on  transaction leak profiling
save()
activate()
exit()

Note that you can "or" multiple profile options together when setting the profile type. 

In the administrative console on the Diagnostics Tab, this may be enabled using the Profile Connection Local Transaction Leak checkbox. 

The local transaction leak profile record contains two stack
traces, one of the reserving thread and one of the thread at the time the
connection was closed. An example log
record is shown below.

####<mydatasource>
<WEBLOGIC.JDBC.CONN.LOCALTX_LEAK> <Thu Apr 09 15:30:11 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)
...

> <java.lang.Exception
at
weblogic.jdbc.common.internal.ConnectionPool.release(ConnectionPool.java:1064)
at
weblogic.jdbc.common.internal.ConnectionPoolManager.release(ConnectionPoolManager.java:189)
at
weblogic.jdbc.wrapper.PoolConnection.doClose(PoolConnection.java:249)
at
weblogic.jdbc.wrapper.PoolConnection.close(PoolConnection.java:157)
...

> <[partition-id: 0] [partition-name: DOMAIN] >

Once you look at the record, you can see where in the application the close is done and you should complete the transaction appropriately before doing the close.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.