WebLogic Common Failure One: JDBC Connection pools

Source: Internet
Author: User
Tags connection pooling stack trace what sql

Tag: XSD Pass program waits for IDA manager ring stack trace hint

Recently, the system is always the database connection pool is not enough, because the WebLogic data source does not configure the number of JDBC connections, take the default value of 15, too small cause connection exhausted, is not to report a heap of errors. The problem was later resolved by modifying the WebLogic data source configuration file. Here are the steps to resolve:

Step 1: View the descriptor-file-name of JDBC in the Weblogic\middleware\user_projects\domains\base_domain\config\config.xml file

<jdbc-system-resource>
<name>ysjnditest</name>
<target>AdminServer</target>
<descriptor-file-name>jdbc/ysjnditest-jdbc.xml</descriptor-file-name>
</jdbc-system-resource>

Step 2: Modify the corresponding file: weblogic\middleware\user_projects\domains\base_domain\config\jdbc\ysjnditest-jdbc.xml file, Add Initial-capacity, max-capacity, min-capacity configurations.

Cases:

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>
<jdbc-data-source xmlns= "Http://xmlns.oracle.com/weblogic/jdbc-data-source" xmlns:sec= "http// Xmlns.oracle.com/weblogic/security "xmlns:wls=" http://xmlns.oracle.com/weblogic/security/wls "xmlns:xsi="/HTTP/ Www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Http://xmlns.oracle.com/weblogic/jdbc-data-source http:/ /xmlns.oracle.com/weblogic/jdbc-data-source/1.2/jdbc-data-source.xsd ">
<name>jcjywjndi</name>
<jdbc-driver-params>
<url>jdbc:oracle:thin:@172.30.118.59:1521:develop</url>
<driver-name>oracle.jdbc.OracleDriver</driver-name>
<properties>
<property>
<name>user</name>
<value>jcjyw</value>
</property>
</properties>
<password-encrypted>{AES}9xKyHoUWXjM8QSqISoEHMJ/ZfA/ZtL2BQDsJrbgMU04=</password-encrypted>
</jdbc-driver-params>
<jdbc-connection-pool-params>
<initial-capacity>5</initial-capacity>
<max-capacity>50</max-capacity>
<min-capacity>5</min-capacity>
<test-table-name>sql SELECT 1 from dual</test-table-name>
</jdbc-connection-pool-params>
<jdbc-data-source-params>
<jndi-name>jcjywjndi</jndi-name>
<global-transactions-protocol>None</global-transactions-protocol>
</jdbc-data-source-params>
</jdbc-data-source>

After the problem solved, found some related articles on the net, below this thought is also good, shares with everybody.

Original:

Database connection pooling in WebLogic server is a frequently problematic place to summarize the causes and workarounds for the problem.

one, the database connection leaks
This type of problem is typically caused by a developer not shutting down the database connection properly. For example, after using connection, the Connection.close () method is not called.

1. Diagnostic Methods
In console, locate connection pools Tab and diagnostics, set the following properties (different versions may differ slightly)
Enable Connection Leak Profiling enables monitoring of connection pool leaks.
Enable Connection Profiling enables connection pooling monitoring.
Inactive Connection Timeout 100 means that invalid connections are forced to be reclaimed after 100 seconds. The default of 0 means that the connection pool is released back when it is exhausted.
Without rebooting, look at the log of the server, look for "A JDBC pool connection leak was detected", and if so, see which class is causing it. Here is an example of a database connection leak:
A JDBC Pool connection leak was detected.
A connection leak occurs when a connection obtained from the pool is not closed explicitly by
Calling close () and then is disposed by the garbage collector and returned to the connection pool.
The following stack trace at create shows where the leaked connection is created.
Stack Trace at Connection create:
At Weblogic.jdbc.wrapper.JTAConnection.init (jtaconnection.java:90)
At Weblogic.jdbc.jta.DataSource.getConnection (datasource.java:468)
At Weblogic.jdbc.jta.DataSource.connect (datasource.java:410)
At Weblogic.jdbc.common.internal.RmiDataSource.getConnection (rmidatasource.java:344)
At Troubleshooting.servlets.JdbcConnections.service (jdbcconnections.java:97)
At Javax.servlet.http.HttpServlet.service (httpservlet.java:853)
At Weblogic.servlet.internal.servletstubimpl$servletinvocationaction.run (servletstubimpl.java:1077)
At Weblogic.servlet.internal.ServletStubImpl.invokeServlet (servletstubimpl.java:465)
At Weblogic.servlet.internal.ServletStubImpl.invokeServlet (servletstubimpl.java:348)
At Weblogic.servlet.internal.webappservletcontext$servletinvocationaction.run (webappservletcontext.java:7047)
At Weblogic.security.acl.internal.AuthenticatedSubject.doAs (authenticatedsubject.java:321)
At Weblogic.security.service.SecurityManager.runAs (securitymanager.java:121)
At Weblogic.servlet.internal.WebAppServletContext.invokeServlet (webappservletcontext.java:3902)
At Weblogic.servlet.internal.ServletRequestImpl.execute (servletrequestimpl.java:2773)
At Weblogic.kernel.ExecuteThread.execute (executethread.java:224)
At Weblogic.kernel.ExecuteThread.run (executethread.java:183)
After the problem is resolved, set the three property back to the previous value.
2. Solution
Close the database connection correctly. The specific code is as follows:
Connection conn = null;
ResultSet rs = null;
PreparedStatement pss = null;
try {
conn = Datasource.getconnection (Userid,password);
PSS = Conn.preparestatement ("Select Saveserialzeddata from Session.pingsession3data WHERE
SessionKey =? ");
Pss.setstring (1,sessionkey);
rs = Pss.executequery ();
Pss.close ();
}
catch (Throwable t) {}
finally {
Try
{
IF (conn! = null) conn.close ();
}
catch (Exception e) {}
}

Second, the database connection is not enough

The main reasons why the database connection is not sufficient are:
① Some programs take too long to connection, and if multiple users are using these programs at the same time, they can result in insufficient connectivity.
② thread deadlock, unable to release connection.
1. Diagnostic Methods
① monitoring parameters: Waiting for Connection high Count
[domain_name]-> enviroment, Servers, [Server], monitoring, JDBC View parameters: Waiting for Connection high Cou Nt
If you do not have this parameter, add it manually, which represents the maximum number of applications waiting to be connected without an available connection. Adjusted connection Pool Max = The connection pool maximum value before adjustment + waiting for Connection high Count. In general, the size of the database connection pool is equal to the optimal number of concurrent users.

② in the server log, explicitly throws the following exception:
Java.sql.SQLException:Internal Error:cannot Obtain Xaconnection
Weblogic.common.resourcepool.ResourceLimitException:No resources currently available in pool
Bankconnectionpool to allocate to applications, please increase the size of the pool and retry.
At Weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist (datasource.java:1493)
At Weblogic.jdbc.jta.DataSource.getConnection (datasource.java:455)
At Weblogic.jdbc.jta.DataSource.connect (datasource.java:410)
At Weblogic.jdbc.common.internal.RmiDataSource.getConnection (rmidatasource.java:344)
At Troubleshooting.servlets.JdbcConnections.service (jdbcconnections.java:80)
At Javax.servlet.http.HttpServlet.service (httpservlet.java:853)
At Weblogic.servlet.internal.servletstubimpl$servletinvocationaction.run (servletstubimpl.java:1077)
At Weblogic.servlet.internal.ServletStubImpl.invokeServlet (servletstubimpl.java:465)
At Weblogic.servlet.internal.ServletStubImpl.invokeServlet (servletstubimpl.java:348)
At Weblogic.servlet.internal.webappservletcontext$servletinvocationaction.run (webappservletcontext.java:7047)
At Weblogic.security.acl.internal.AuthenticatedSubject.doAs (authenticatedsubject.java:321)
At Weblogic.security.service.SecurityManager.runAs (securitymanager.java:121)
At Weblogic.servlet.internal.WebAppServletContext.invokeServlet (webappservletcontext.java:3902)
At Weblogic.servlet.internal.ServletRequestImpl.execute (servletrequestimpl.java:2773)
At Weblogic.kernel.ExecuteThread.execute (executethread.java:224)
At Weblogic.kernel.ExecuteThread.run (executethread.java:183)
If you observe connection monitoring at this time, you will find that all connection are active, and there are a large number of requests waiting for connection.
2. Solution
① increase the number of maximum capacity, which is generally slightly larger than the number of database connections in peak conditions. Services > JDBC > Connection pools > Bankconnectionpool > Configuration > Connections
② focuses on checking the synchronize code snippet and the code that involves the database lock. If necessary, look at thread dump to see what the thread is doing and what it is waiting for.

Third, database connection use timeout
This type of problem is generally due to some database operation time is longer than the inactive connection timeout setting.
1. Diagnostic Methods
In server log, you explicitly have the following prompt, and you are prompted to throw an application exception:
Forcibly releasing inactive resource "[email protected]" Back to the pool Bankconnectionpool ". The application exception cannot be listed here because each app is different, However, there is a good chance that a null pointer exception will be thrown because connection is forced back into the pool, and continuing to use an empty object throws the exception.
2. Solution
In the advanced parameters, increase the number of inactive connection timeout.
Services > JDBC > Connection pools > Bankconnectionpool > Configuration > Connections

Iv. Transaction Timeout
This type of problem is generally due to some database operation time is longer than the JTA Timeout seconds settings.
1. Diagnostic Methods
In server log, explicitly throw an exception:
Weblogic.transaction.internal.TimedOutException:Transaction timed out after seconds
2. Solution
Increase the number of services > JTA Configuration > Timeout seconds.
Note that this parameter should be less than the value of inactive connection timeout, because the transaction must be completed before the connection times out. If you want to analyze what SQL statements are causing transactions to time out, you can turn on log adminserver > Logging > JDBC, check Enable JDBC Logging, and set the JDBC log File Name.

WebLogic Common Failure One: JDBC Connection pools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.