Troubleshooting
Problem
During the testing or troubleshooting of an enterprise application, it may become necessary to purge the connection pool of a WebSphere Application Server data source of existing connections.
Symptom
Changes to the application or environment may invalidate cached connections in the Connection Manager pool. Although these connections will eventually be discarded through the normal processing of the connection requests, it may be desirable to purge them all at once and allow the pool to refill with new, valid connections.
Resolving The Problem
WebSphere Application Server has an operation on the data source MBean that can be used to purge the connection pool. WebSphere Application Server MBean may be called via the wsadmin console, see the IBM Information Center topic "Scripting the application serving environment (wsadmin)" for more details. The operation name is: purgePoolContents.
The purgePoolContents operation has two options:
Examples of operations that can be executed on the data source MBean using the wasdmin console:
The purgePoolContents operation has two options:
- Normal:
- This is the default option.
- Existing in-flight transactions will be allowed to continue work.
- Shared connection requests will be honored.
- Free connections are cleaned up and destroyed.
- In use connections (for example: connections in transactions) are cleaned up and destroyed when returned to the connection pool.
- A close() call issued on any connection obtained prior to the
purgePoolContents
will be done synchronously (for example: wait for the jdbc driver to return before proceeding). - Requests for new connections (not handles to existing old connections) will be honored.
- Immediate:
- No new transactions will be allowed to start on any connections obtained prior to the
purgePoolContents
call. Instead, a StaleConnectionException is thrown. - No new handles will be handed out on any connections obtained prior to the
purgePoolContents
call. Instead, a StaleConnectionException is thrown. - Existing in-flight transactions will be allowed to continue work. Any new activities on a purged Connection will cause a StaleConnectionException or an XAER_FAIL exception (in the case of XA)
- A close() call issued on any connection obtained prior to the
purgePoolContents
call will be done asynchronously (for example: no waiting for the jdbc driver to return) This is useful if the driver returns. - Due to the fact that close() does not wait, the number of connections will be decremented immediately in WebSphere Application Server. This might cause the total number of connections in WebSphere Application Server to be temporarily out of sync with the database total number of connections.
- Requests for new connections (for example: not handles to existing old connections) will be honored.
- No new transactions will be allowed to start on any connections obtained prior to the
Examples of operations that can be executed on the data source MBean using the wasdmin console:
- List all data sources:
Using Jacl:
$AdminControl queryNames *:type=DataSource,*
Using Jython:
AdminControl.queryNames("*:type=DataSource,*")
- Initialize a variable to specify a data source (this example uses Default Datasource, but any data source name listed in the output of above command can be used):
Using Jacl:
set name "Default Datasource"
set ds [$AdminControl queryNames *:type=DataSource,name=$name,*]
Using Jython:
name = "Default Datasource"
ds = AdminControl.queryNames("*:type=DataSource,name="+name+",*")
- View the pool contents by invoking the showPoolContents operation of the data source MBean:
Using Jacl:
$AdminControl invoke $ds showPoolContents
Using Jython:
print AdminControl.invoke(ds, "showPoolContents")
- View contents of all pools by invoking the showAllPoolContents operation of the data source MBean:
Using Jacl:
$AdminControl invoke $ds showAllPoolContents
Using Jython:
print AdminControl.invoke(ds, "showAllPoolContents")
- Immediately purge the pool by invoking the purgePoolContents operation of the data source MBean with the immediate option:
Using Jacl:
$AdminControl invoke $ds purgePoolContents immediate
Using Jython:
AdminControl.invoke(ds, "purgePoolContents", "immediate")
[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"DB Connections\/Connection Pooling","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"9.0;8.5.5;8.0","Edition":"Base;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SS7K4U","label":"WebSphere Application Server for z\/OS"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"8.0;7.0;6.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]
Was this topic helpful?
Document Information
Modified date:
18 November 2019
UID
swg21220832