datasource - Spring BasicDataSource pool to perform WHEN_EXHAUSTED_GROW behaviour -
when uploaded our application on prod server faced unusual behaviour - stopped info data base of operations though logic , right , local version working perfect. after remote debugging found genericobjectpool blocking thread. , after time spent on searching found situation fits our problem. pool got exhausted when filled 8 connections (default value) , default it's behaviour set block thread when exhausted.
here datamodel-context.xml config of basicdatasource
<bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver"/> <property name="url" value="url_to_db"/> <property name="username" value="username"/> <property name="password" value="12211"/> <property name="defaultautocommit" value="false"/> <property name="poolpreparedstatements" value="true"/> <property name="initialsize" value="10"/> <property name="maxidle" value="5"/> <property name="testonborrow" value="true"/> <property name="logabandoned" value="true"/> </bean>
found here 2 solutions - increment max active number or alter pool's behaviour. first 1 seems simple - set property maxactive in basicdatasource number (please right me if mistaking). way unwanted because can not know exact number of possible simultanious connections.
it decided seek sec way - alter behaviour when_exhausted_grow. there way configure spring default pool alter it's whenexhaustedaction behaviour? or should define own connection pool basicdatasource? if so, please can provide examples? appreciate comments or advices. thanks.
spring datasource connection-pooling
No comments:
Post a Comment