Atomikos Forum

Connections are not closed. (Connection pool exhausted)

Hi Guys,

I am a new in the XA transactions. I want to to use only one connections to each of my databases (I have 3 in my application) so when transaction is performer I want connection to be closed but I got 'Could not get JDBC Connection; nested exception is com.atomikos.jdbc.AtomikosSQLException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.' exeption instead.

here are my configuration files:

database.url=jdbc\:oracle\:thin\:@localhost\:1521\:XASID
database.poolPreparedStatements=true
database.minPoolSize=1
database.maxPoolSize=3
database.databaseCode=CODE

  <bean id="siteDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
    init-method="init" destroy-method="close" lazy-init="true">
    <property name="uniqueResourceName" value="siteDataSource" />
    <property name="xaDataSource" ref="siteDataBase" />
    <property name="minPoolSize" value="${database.minPoolSize}" />
    <property name="maxPoolSize" value="${database.maxPoolSize}"/>
    <property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
    <property name="testQuery"><value>SELECT 1 FROM DUAL</value></property>
  </bean>


  <bean id="siteDataBase" class="oracle.jdbc.xa.client.OracleXADataSource"
    lazy-init="true" destroy-method="close">
    <property name="URL" value="${database.url}"/>
    <property name="user" value="${database.dashboard.cx.spring.user}"/>
    <property name="password" value="${database.dashboard.cx.spring.password}"/>
  </bean>


  <bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
      init-method="init" destroy-method="shutdownForce">
    <constructor-arg>
      <props>
        <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
      </props>
    </constructor-arg>
  </bean>

  <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
      init-method="init" destroy-method="close" depends-on="userTransactionService">
    <property name="forceShutdown" value="false"/>
  </bean>

  <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"
      depends-on="userTransactionService">
    <property name="transactionTimeout" value="300"/>
  </bean>

  <bean id="distributedManager" class="org.springframework.transaction.jta.JtaTransactionManager"
      depends-on="atomikosTransactionManager,atomikosUserTransaction">
    <property name="transactionManager" ref="atomikosTransactionManager"/>
    <property name="userTransaction" ref="atomikosUserTransaction"/>
    <property name="allowCustomIsolationLevels" value="true" />
  </bean>



730641 [Atomikos:9] DEBUG c.a.datasource.pool.ConnectionPool - atomikos connection pool 'siteDataSource': connection idle for 726779ms
730641 [Atomikos:9] DEBUG c.a.datasource.pool.ConnectionPool - atomikos connection pool 'siteDataSource': connection idle for 603973ms
730641 [Atomikos:9] DEBUG c.a.datasource.pool.ConnectionPool - atomikos connection pool 'siteDataSource': connection idle for 35354ms
730642 [Atomikos:9] DEBUG c.a.datasource.pool.ConnectionPool - atomikos connection pool 'siteDataSo732889 [scheduler_Worker-5] WARN  c.a.jdbc.AtomikosSQLException - Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.urce': current size: 0/3


Why I see 'connection idle for ...' message? Why my connection is not closed and every time when my code runs I have new connection created.

I don't want to have connection opened. Please let me know if I did something wrong or if I missed smtg in parameters. I use @Transaction annotation and rollback works fine.

Thanks in advance.
khelenik Send private email
Friday, September 11, 2015
 
 
Whatever component in your configuration is getting JDBC connections: it does not seem like it is closing them. That would be the thing to check...

HTH
Guy Pardon Send private email
Sunday, September 13, 2015
 
 
Should it be closed automatically if I use Spring and @Transactional annotation? I debugged atomikos source code and it looks like it doesn't close connection because XPooledConnection.isAvailable() always returns 'false' since for connection is set to BranchEndedStateHandler state not in TerminatedStateHandler.
khelenik Send private email
Monday, September 14, 2015
 
 
The Spring @Transactional annotation does nothing to close connections AFAIK. You have to look elsewhere, where the datasource is being used.
Guy Pardon Send private email
Monday, September 14, 2015
 
 
I don't really know about spring (and you don't tell whether you use some ORM or other database abstractions) but e.g. Hibernate does the connection release in a JTA synchronization (and that propably is the only sensible way to do it).

And ... there is a bug in atomikos which has gone unfixed - at least in the essentials version - for quite some while (reported e.g. here default82df.html?community.6.3162.9 ) which results in the synchronization not being notified for read-only transactions if multiple participants are involved.

This is the fix we have been using for quite a while now
https://gist.github.com/mbechler/37c4795a2057d2451b4e
Moritz Bechler Send private email
Friday, September 18, 2015
 
 
Moritz thanks, this fix helped me to fix issue.
khelenik Send private email
Wednesday, September 23, 2015
 
 
For the record: this issue should have been fixed in release 3.9.13
Guy Pardon Send private email
Wednesday, September 30, 2015
 
 
We are also getting the same error

org.springframework.orm.jpa.JpaSystemException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.; nested exception is <openjpa-2.3.0-r422266:1540826 fatal general error> org.apache.openjpa.persistence.PersistenceException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.
      at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:418) ~[spring-orm-4.0.5.RELEASE.jar:4.0.5.RELEASE]


We are using 3.9.3 and our number of connections is 10.

Any help would be greatly appreciated.
Pavan Madiraju Send private email
Friday, October 16, 2015
 
 
Again: upgrading to the commercial 3.9.x releases will help.
Guy Pardon Send private email
Saturday, October 17, 2015
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics