Page 1 of 5 123 ... LastLast
Results 1 to 10 of 42

Thread: configuration help: pool problems create deadlocks

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Exclamation configuration help: pool problems create deadlocks

    hello guys

    i am in trouble with deadlocks about pool control

    in my project with Spring for database section i work with Hibernate and for jasper reports i work with the classic jdbc

    today, after to almost 30 minutes of test, my application is suddenly dead , stop
    after to done thread dump

    i see this part
    Code:
    "http-8080-Processor23" daemon prio=1 tid=0xa8624a20 nid=0x1a09 in Object.wait() [0xa72f9000..0xa72fae40]
    	at java.lang.Object.wait(Native Method)
    	- waiting on <0xab3e47e8> (a com.mchange.v2.resourcepool.BasicResourcePool)
    	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:968)
    	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
    	- locked <0xab3e47e8> (a com.mchange.v2.resourcepool.BasicResourcePool)
    	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:260)
    	at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
    	at com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)
    	at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
    	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
    	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
    	at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
    	at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    	at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    	at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:497)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:349)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:255)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:616)
    	at com.lagranjita.modelo.bo.implementaciones.concretos.ConcreteCabeceraCuentaProveedoresImpl$$EnhancerByCGLIB$$61ebcf9a.getAllCabeceraCuentaProveedoresInFormalesBO(<generated>)
    after to see some threads i have this configuration
    (remember that i work with Hibernate and jdbc)

    i have only 2 context for configuration for the db

    One: for general db connection
    Code:
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">							 
            <property name="driverClass">
                <value>com.mysql.jdbc.Driver</value>
            </property>
            <property name="jdbcUrl">
    		<value>jdbc:mysql://localhost:3306/mydb</value>
            </property>
            <property name="user">
                <value>someuser</value>
            </property>
            <property name="password">
                <value>somepassword</value>
            </property>
            <property name="acquireIncrement">
                <value>3</value>
            </property>
            <property name="minPoolSize">
                <value>6</value>
            </property>
            <property name="maxPoolSize">
                <value>26</value>
            </property>
            <property name="maxStatementsPerConnection">
                <value>100</value>
            </property>
            <property name="idleConnectionTestPeriod" >
                <value>3000</value>
            </property>
            <property name="automaticTestTable">
                <value>c3p0_test_table</value>
            </property>
            <property name="numHelperThreads">
                <value>20</value>
            </property>
        </bean>
    Two: for hibernate
    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    	<property name="dataSource">
    		<ref bean="dataSource"/>
    	</property>
    	<property name="mappingResources">
    		<list>a lot of hhm files </list>
    	</property>
    	<property name="hibernateProperties">
    		<props>
            	<!-- SQL dialect -->
    		<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
    
                    <!-- JDBC connection pool (use the built-in) -->
    		<!-- <prop key="hibernate.connection.pool_size" >1</prop>  -->
    
    		<!-- Enable Hibernate's automatic session context management -->
    		<prop key="hibernate.current_session_context_class" >thread</prop>
    
    		<!-- Disable the second-level cache  -->
    	 	<prop key="hibernate.cache.provider_class" >org.hibernate.cache.NoCacheProvider</prop>
    
    		<!-- Echo all executed SQL to stdout -->
    		<prop key="hibernate.show_sql" >true</prop>			
    					
    		<!-- Drop and re-create the database schema on startup -->
     		<prop key="hibernate.hbm2ddl.auto" >create-drop</prop> 
    
    <!-- 
    		<prop key="hibernate.c3p0.min_size" >5</prop>
    		<prop key="hibernate.c3p0.max_size" >20</prop>									<prop key="hibernate.c3p0.timeout" >300</prop>
    		<prop key="hibernate.c3p0.max_statements" >50</prop>							<prop key="hibernate.c3p0.idle_test_preriod" >3000</prop>
     -->										
    	     </props>
          </property>
    </bean>   
    
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory">
    			<ref bean="sessionFactory"/>
    		</property>
    </bean>				
    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
       	     <property name="sessionFactory">
            	   <ref bean="sessionFactory"/>
             	</property>
    </bean>
    so pls, what is wrong in my configuration???
    i think that our members has the correct configuration

    share your configuration

    thanks for advanced
    Last edited by dr_pompeii; Jun 24th, 2007 at 11:42 AM.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    The deadlocks I've encountered have usually been related to the code rather than the configuration. Have you tracked down which code actually causes the deadlock? If you run the tests from eclipse when it grinds to a halt you should be able to see whats got a lock on what.

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello karldmoore

    The deadlocks I've encountered have usually been related to the code rather than the configuration
    mmm, wondered

    Have you tracked down which code actually causes the deadlock?
    no directly, but i saw when i use in my tests (no JUnit) a lot of jasperreports to generate the pdf reports, i see the deadlock, the jasperreports work with jdbc

    If you run the tests from eclipse when it grinds to a halt you should be able to see whats got a lock on what.
    i see this hard, in any time in any action and any moment is all down
    of course
    thats happens when i use a lot of the jasperreports

    karl, my configuration is right?

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    It looks like it's leaking connections, I'd suggest having a quick review over any code that handles connections and ensure that they are closed.
    Last edited by karldmoore; Aug 29th, 2007 at 11:19 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    thanks for the reply friend

    this is for example a class (of many that i have) related with JR,
    all has the same style of programming

    Code:
    package com.lagranjita.swf.actions;
    
    import java.sql.Connection;
    import java.sql.ResultSet;
    //import java.sql.Statement;
    
    import java.sql.PreparedStatement;
    //import java.sql.SQLException;
    
    import javax.sql.DataSource;
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    
    import org.springframework.webflow.execution.Event;
    import org.springframework.webflow.action.AbstractAction;
    import org.springframework.webflow.execution.RequestContext;
    
    
    import com.lagranjita.modelo.entidades.AlmacenPK;
    import com.lagranjita.modelo.entidades.CabeceraSalidaAlmacen;
    
    import net.sf.jasperreports.engine.JRResultSetDataSource;
    
    //com.lagranjita.swf.actions.TransaccionSalidaAlmacenJasperReportAction
    public class TransaccionSalidaAlmacenJasperReportAction extends AbstractAction {
    
    	private static Log logger = LogFactory.getLog("TransaccionSalidaAlmacenJasperReportAction");
    	
    	private DataSource dataSource;
    	  
    	public void setDataSource (DataSource dataSource){
    	    this.dataSource=dataSource;
    	}
    	
    	@Override
    	protected Event doExecute(RequestContext context)throws Exception{
    		logger.info("doExecute");
    		CabeceraSalidaAlmacen cabeceraSalidaAlmacen = (CabeceraSalidaAlmacen) (context.getFlowScope().get("cabeceraSalidaAlmacenCommand"));
    		AlmacenPK almacenPK = cabeceraSalidaAlmacen.getAlmacenPK();
    		
    	    Connection connection;
    	    PreparedStatement ps;
    	    ResultSet resultSet;
    	   	    
    	    String query = "SELECT * FROM CabeceraAlmacen c, DetalleAlmacen d, Articulo a, Medida m  WHERE " +
    	    		" c.idnumero=d.idnumero AND c.serie=d.serie AND " +
    	    		" d.idArticulo=a.idArticulo AND a.idMedida=m.idMedida AND " +
    	    		" c.serie='SAL' AND c.idnumero=?";
    	    		 
    	    connection = dataSource.getConnection();
    	    ps=connection.prepareStatement(query);
    	    ps.setString(1, almacenPK.getIdnumero());
    	    resultSet = ps.executeQuery();	    
    	    
    	    JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(resultSet);
    	    context.getRequestScope().put("datasource", resultSetDataSource);
    	    return success();
    	}	
    }
    the class already posted is for SWF , but for spring mvc is the same history

    and ensure that they are closed.
    sorry for my ignorance but with this
    Code:
    <bean id="dataSource"
              class="com.mchange.v2.c3p0.ComboPooledDataSource"   
              destroy-method="close">
    is not enough?
    i see that my code doesnt has a line to close the connection,
    only has a line to get the connection
    like
    Code:
    connection = dataSource.getConnection();
    now for the bean definition i have this
    Code:
    <bean id="idTransaccionSalidaAlmacenJasperReportAction" class="com.lagranjita.swf.actions.TransaccionSalidaAlmacenJasperReportAction" >
        	<property name="dataSource">
    		<ref bean="dataSource" />
    	</property>
    </bean>
    i need your experience and help

    thanks for advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    So if you're not closing the connection, who is?
    Code:
    connection = dataSource.getConnection();
    Last edited by karldmoore; Aug 29th, 2007 at 11:19 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  7. #7
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    who is?
    is for the execution of sql query
    Code:
     connection = dataSource.getConnection();
     ps=connection.prepareStatement(query);
     ps.setString(1, almacenPK.getIdnumero());
     resultSet = ps.executeQuery();	    
    	    
     JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(resultSet);
     context.getRequestScope().put("datasource", resultSetDataSource);
     return success();
    i dont understand your question

    i work with jdbc for jasper reports

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Sorry, what I was getting at is who actually releases the connection in this example? I've never worked with this kind of JRDataSource before. I've typically worked with JRBeanCollectionDataSource.
    http://jasperreports.sourceforge.net...ataSource.html
    Last edited by karldmoore; Aug 29th, 2007 at 11:19 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  9. #9
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    hi karl

    thanks for the reply

    http://jasperreports.sourceforge.net...ataSource.html
    Code:
    Constructor Summary 
    JRResultSetDataSource(java.sql.ResultSet rs)
    Code:
    Constructor Summary 
    JRBeanCollectionDataSource(java.util.Collection beanCollection)
    i need work with ResultSet , because my results is a mix o merge of various fields of many classes, so i cant use Collection

    but tell me , your class against the mime, the pool resource is managed by spring right?, already defined in the context

    the way that i used to work in code, is almost in 98% the same that in my example book

    i am lost

    pls help

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  10. #10
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    What I was getting at here though is what releases the ResultSet?
    Last edited by karldmoore; Aug 29th, 2007 at 11:18 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •