掲示板

Why is liferay opening multiple connections on other JNDI connection pools?

9年前 に Tobia Conforto によって更新されました。

Why is liferay opening multiple connections on other JNDI connection pools?

New Member 投稿: 4 参加年月日: 10/06/26 最新の投稿
Hello

I'm trying to configure a JNDI connection pool in Liferay's container (Tomcat) for use by another web application, that will be published in the same container.

Here is the basic connection pool I've put in tomcat-7.0.42/conf/context.xml:

<resource name="jdbc/myName" auth="Container" type="javax.sql.DataSource" initialSize="5" minIdle="5" maxIdle="10" maxActive="10" maxWait="10000" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.10.16:3306/myName" username="xxx" password="yyy" />

The problem is that Liferay, even by itself without the other application published anywhere, will open a huge amount of connections to this DB, apparently in groups of 5:

$ mysqladmin processlist 
+-------+-----------------+----------------------+------------------+---------+------+-------+------------------+
| Id    | User            | Host                 | db               | Command | Time | State | Info             |
+-------+-----------------+----------------------+------------------+---------+------+-------+------------------+
| 36940 | xxxxx           | 192.168.10.16:57512  | myName           | Sleep   | 386  |       |                  |
| 36941 | xxxxx           | 192.168.10.16:57513  | myName           | Sleep   | 386  |       |                  |
| 36942 | xxxxx           | 192.168.10.16:57514  | myName           | Sleep   | 386  |       |                  |
| 36943 | xxxxx           | 192.168.10.16:57515  | myName           | Sleep   | 386  |       |                  |
| 36944 | xxxxx           | 192.168.10.16:57516  | myName           | Sleep   | 386  |       |                  |
| 36967 | xxxxx           | 192.168.10.16:57579  | myName           | Sleep   | 341  |       |                  |
| 36968 | xxxxx           | 192.168.10.16:57580  | myName           | Sleep   | 341  |       |                  |
| 36969 | xxxxx           | 192.168.10.16:57581  | myName           | Sleep   | 341  |       |                  |
| 36970 | xxxxx           | 192.168.10.16:57582  | myName           | Sleep   | 341  |       |                  |
| 36971 | xxxxx           | 192.168.10.16:57583  | myName           | Sleep   | 341  |       |                  |
| 36973 | xxxxx           | 192.168.10.16:57585  | myName           | Sleep   | 339  |       |                  |
| 36974 | xxxxx           | 192.168.10.16:57586  | myName           | Sleep   | 339  |       |                  |
| 36975 | xxxxx           | 192.168.10.16:57587  | myName           | Sleep   | 339  |       |                  |
| 36976 | xxxxx           | 192.168.10.16:57588  | myName           | Sleep   | 339  |       |                  |
| 36977 | xxxxx           | 192.168.10.16:57589  | myName           | Sleep   | 339  |       |                  |
| 36979 | xxxxx           | 192.168.10.16:57591  | myName           | Sleep   | 338  |       |                  |
| 36980 | xxxxx           | 192.168.10.16:57592  | myName           | Sleep   | 338  |       |                  |
| 36981 | xxxxx           | 192.168.10.16:57593  | myName           | Sleep   | 338  |       |                  |
| 36982 | xxxxx           | 192.168.10.16:57594  | myName           | Sleep   | 338  |       |                  |
| 36983 | xxxxx           | 192.168.10.16:57595  | myName           | Sleep   | 338  |       |                  |
...

There are 14 groups of 5 connections being open. The former number follows the initialSize and minIdle of the pool, so if I put 3 into context.xml I get 14 groups of 3 connections.

I don't understand why Liferay is opening these connections. In portal-ext.properties there is no JNDI configuration at all:

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://192.168.10.16:3306/liferayDbName
jdbc.default.username=xxx
jdbc.default.password=yyy

How can I tell Liferay not to touch that pool, which I've put there to be used by another application?

I'm using Liferay 6.2 CE GA2, on Debian Linux with OpenJDK 1.7.0_65 64bit Server VM
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Why is liferay opening multiple connections on other JNDI connection po

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Why do you assume it is Liferay?

It's a tomcat JNDI object definition that (unless you've done something you haven't shared) isn't even used by Liferay...
9年前 に Tobia ƒ によって更新されました。

RE: Why is liferay opening multiple connections on other JNDI connection po

New Member 投稿: 4 参加年月日: 10/06/26 最新の投稿
You are right.

I assumed it was Liferay because a standalone Tomcat, with just the application I was developing, would only create 5 connections, not a disproportionate number.

In reality the problem was the initialSize attribute. If set to > 0, Tomcat will create that number of connections for every registered web application, even those that will never use that pool. Liferay's Tomcat had a dozen of web application, so Tomcat would create 60+ connections.