com.atomikos.jdbc.AtomikosSQLException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the

Viewed 1653

In my spring batch application, i'm using atomikos version(4.0.4) and JTA(1.1).Some of the jobs are hanged in PROD and acquired all the connections from DB which in turns stopped the other jobs which were triggered in parallel. And all were failed with below error.

Error Log 1:
Could not get JDBC Connection; nested exception is com.atomikos.jdbc.AtomikosSQLException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.

Error Log 2 :
Failed to grow connection pool.

And almost for 13 jobs no instance got created in DB and in control-m the logs were captured with "Null Exception Message intercepted"

Can anyone please suggest on this issue? Even tried with upgrading the atomikos version upto 5.0.0 but still same issue occurring.

 {

AtomikosDataSourceBean ads = new AtomikosDataSourceBean();

        if (mDevModeDriverClassName.toLowerCase().contains("oracle")) {
            if (!mDevModeDriverClassName.equals("oracle.jdbc.xa.client.OracleXADataSource")) {
                log.warn("DataSource property 'devModeDriverClassName' should be set "
                        + "to 'oracle.jdbc.xa.client.OracleXADataSource' when using Oracle! " + "Current value is: "
                        + mDevModeDriverClassName);
            }
        }
        String vUniqueResourceName = "DS-" + UUID.randomUUID();
        log.debug("Creating Oracle XA DataSource. uniqueResourceName={}"+vUniqueResourceName);
        ads.setUniqueResourceName(vUniqueResourceName);
        ads.setXaDataSourceClassName(mDevModeDriverClassName); // "oracle.jdbc.xa.client.OracleXADataSource");
        ads.setMaxPoolSize((mDevModeMaxSize > 0) ? mDevModeMaxSize : 1); //mDevModeMaxSize =10
        ads.setTestQuery("SELECT 1 FROM DUAL");      
        Properties xaProps = new Properties();
        xaProps.setProperty("user", mDevModeUsername);
        xaProps.setProperty("password", mDevModePassword);
        xaProps.setProperty("URL", mDevModeJdbcUrl);
        ads.setXaProperties(xaProps); 
        OracleXADataSource xaDataSource = new OracleXADataSource();
        xaDataSource.setUser(mDevModeUsername);
        xaDataSource.setPassword(mDevModePassword);
        xaDataSource.setURL(mDevModeJdbcUrl);
        ads.setXaDataSource(xaDataSource);

<bean id="rsDataSource" class="com.sample.CustomDataSource" scope="singleton" destroy-method="close">       
        <property name="devModeDriverClassName" value="${spring.datasource.driver-class-name}" />
        <property name="devModeJdbcUrl" value="${spring.datasource.rs.url}" />
        <property name="devModeUsername" value="${spring.datasource.rs.username}" />
        <property name="devModePassword" value="${spring.datasource.rs.password}" />
        <property name="devModeMaxSize" value="10" />  
    </bean> 
 <bean id="transactionManager"
          class="org.springframework.transaction.jta.JtaTransactionManager"  >
        <property name="nestedTransactionAllowed" value="true"/>
        <property name="allowCustomIsolationLevels" value="true"/>
        <property name="defaultTimeout" value="-1"/> 
        <property name="transactionManager"  ref="txManager"></property>
   </bean>
   
   <bean id="txManager" class="com.atomikos.icatch.jta.UserTransactionManager" destroy-method="close">
        <property name="forceShutdown" value="true"/>
        <property name="transactionTimeout" value="60"></property>
        
   </bean> 
1 Answers

You either have a connection leak or your pool size is not rightly configured. And looking at your config, it is most likely that your connection pool size is not correctly configured:

And almost for 13 jobs no instance got created

ads.setMaxPoolSize((mDevModeMaxSize > 0) ? mDevModeMaxSize : 1); //mDevModeMaxSize =10

<property name="devModeMaxSize" value="10" />

Your connection pool is set to serve at most 10 connections, but you are launching 13 jobs. So it should not be surprising to have the error:

Connection pool exhausted - try increasing 'maxPoolSize'

You need to increase the maxPoolSize accordingly.

Related