Announcement Announcement Module
Collapse
No announcement yet.
configuration help: pool problems create deadlocks Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 11:42 AM.

  • #2
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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, 11:19 AM.

        Comment


        • #5
          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

          Comment


          • #6
            So if you're not closing the connection, who is?
            Code:
            connection = dataSource.getConnection();
            Last edited by karldmoore; Aug 29th, 2007, 11:19 AM.

            Comment


            • #7
              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

              Comment


              • #8
                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, 11:19 AM.

                Comment


                • #9
                  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

                  Comment


                  • #10
                    What I was getting at here though is what releases the ResultSet?
                    Last edited by karldmoore; Aug 29th, 2007, 11:18 AM.

                    Comment


                    • #11
                      What I was getting at here though is what releases the ResultSet?
                      Code:
                       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=?";
                      see bold part , 4 classes

                      the ResultSet should return a header with its detail used by jasper report , thats all

                      Comment


                      • #12
                        But if you look at your code, you get a connection, execute a query and you have an open ResultSet that you give to Jasper reports. I'm just wondering what actually releases that.
                        Last edited by karldmoore; Aug 29th, 2007, 11:18 AM.

                        Comment


                        • #13
                          But if you look at your code, you get a connection, execute a query and you have an open ResultSet that you give to Jasper reports.
                          thats right, like the book

                          I'm just wondering what actually releases that
                          it seems that i should close the ResultSet right???


                          thanks for advanced

                          Comment


                          • #14
                            Well as I said I haven't used this bit before but I would have thought you'd have to close it once you've generated the report.
                            Code:
                                finally
                                {
                                  //boilerplate code to close the result set, statement, and exception
                                }
                            http://www.ensode.net/jasperreports_database_pg3.html
                            Last edited by karldmoore; Aug 29th, 2007, 11:18 AM.

                            Comment


                            • #15
                              Well as I said I haven't used this bit before but I would have thought you'd have to close it once you've generated the report.
                              yes, it seems, really wondered why this not appear in the book

                              thanks for the link, i am not in my home now so i will test this in the night

                              one favor,can you show an extract of your code, when you use JRBeanCollectionDataSource but with more classes to fill the object,
                              like my case when i use the JRResultSetDataSource???

                              regards

                              and thanks for your time

                              Comment

                              Working...
                              X