jboss datasource statistics JMX monitoring - incon

2019-04-12 14:56发布

问题:

I have defined two datasources in *-ds.xml on jboss 4.2.3 (redhat 4.3) Both datasources are identical. Only jndi-name differ Each defines min=max=10

<xa-datasource>
 <jndi-name>com.trax.hibernate.DataSource</jndi-name>
 <track-connection-by-tx>true</track-connection-by-tx>
 <isSameRM-override-value>false</isSameRM-override-value>
 <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
 <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:orcl10</xa-datasource-property>
 <xa-datasource-property name="User"> xxxx </xa-datasource-property>
 <xa-datasource-property name="Password"> xxxx </xa-datasource-property>
 <min-pool-size>10</min-pool-size>
 <max-pool-size>10</max-pool-size>
 <prefill>true</prefill>
 <blocking-timeout-millis>60000</blocking-timeout-millis>
 <ih3e-timeout-minutes>15</ih3e-timeout-minutes>
 <valid-connection-checker-class-name> org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker </valid-connection-checker-class-name>
 <check-valid-connection-sql>select 1 from gtw_cust</check-valid-connection-sql>
 <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
 <no-tx-separate-pools/>
</xa-datasource>

<xa-datasource>
 <jndi-name>AuditTrail.DataSource</jndi-name>
 <track-connection-by-tx>true</track-connection-by-tx>
 <isSameRM-override-value>false</isSameRM-override-value>
 <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
 <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:orcl10</xa-datasource-property>
 <xa-datasource-property name="User">xxxx</xa-datasource-property>
 <xa-datasource-property name="Password"> xxxx </xa-datasource-property>
 <min-pool-size>10</min-pool-size>
 <max-pool-size>10</max-pool-size>
 <prefill>true</prefill>
 <blocking-timeout-millis>60000</blocking-timeout-millis>
 <ih3e-timeout-minutes>15</ih3e-timeout-minutes>
 <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
 <check-valid-connection-sql>select 1 from gtw_cust</check-valid-connection-sql>
 <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
 <no-tx-separate-pools/>
</xa-datasource>

The problem: On jmx-console, name=com.trax.hibernate.DataSource,service=ManagedConnectionPool, the information shows 20 connections, not 10 as expected.

I would expect the max value of created connections to be 10 (MaxSize). Here is seems that the number of actual connection is double MaxSize, and connections were created and destroyed (40 created and 20 destroyed)

What am I doing wrong? How can you explain this?

com.trax.hibernate.DataSource:
AvailableConnectionCount    20
ConnectionCount           20
MinSize                      10
MaxSize                      10
MaxConnectionsInUseCount    11
InUseConnectionCount              0
ConnectionCreatedCount  40
ConnectionDestroyedCount    20

AuditTrail.DataSource:
AvailableConnectionCount    10
ConnectionCount           10
MinSize                      10
MaxSize                      10
MaxConnectionsInUseCount    8
InUseConnectionCount              0
ConnectionCreatedCount  20
ConnectionDestroyedCount    10

回答1:

That's because of the property <no-tx-separate-pools/>. See the documentation for XA Data Sources, in JBoss Server Configuration Guide:

<no-tx-separate-pools>

Pool transactional and non-transactinal connections separately

Warning

Using this option will cause your total pool size to be twice max-pool-size, because two actual pools will be created.

http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/4.3/html-single/Server_Configuration_Guide/index.html#id2947572