4 Replies Latest reply on Jun 11, 2013 8:34 AM by Ramesh Chokkapu

    sleeped connections return to pool after some time in jboss as 7.1

    Ramesh Chokkapu Newbie

      Hi Good Morning,

       

      My pool stat :

      Here 12 connections are in Active. but only max 2 connection are working, remaining 10 conncetions are in sleep.

      i need these sleeped connections return to pool after some time.

      what i have to do for this?

       

      [standalone@localhost:9999 /] /subsystem=datasources/data-source="MySQLDS"/statistics=pool:read-resource(include-runtime=true)

      {

          "outcome" => "success",

          "result" => {

              "ActiveCount" => "12",

              "AvailableCount" => "150",

              "AverageBlockingTime" => "45",

              "AverageCreationTime" => "49",

              "CreatedCount" => "12",

              "DestroyedCount" => "0",

              "MaxCreationTime" => "276",

              "MaxUsedCount" => "12",

              "MaxWaitTime" => "2",

              "TimedOut" => "0",

              "TotalBlockingTime" => "550",

              "TotalCreationTime" => "596"

          }

      }

       

      Thanks in advance.

        • 1. Re: sleeped connections return to pool after some time in jboss as 7.1
          Wolf-Dieter Fink Master

          To me it is not clear what 'sleeped' connections are. Maybe you have a connection leak where the connections not closed and therefor not marked to returned to pool.

          You should read this wiki and use it to check whether you have such leak.

          • 2. Re: sleeped connections return to pool after some time in jboss as 7.1
            Ramesh Chokkapu Newbie

            Thank for Reply.

             

            Yes, Connection Leak. these leaked connections need to be return to pool after some time.

            DestroyCount should be always  "DestroyedCount" => "0".

             

             

            I have another Question which is :

            --------------------------------------------------

             

            i have hundreds of DAO methods like below.

            some DAO methods, i forgot to session.close() at finally block.

            so my connections are getting to leak (sleep).

            these leaked connections are not return to pool and i need to find where is that leak.

            i have two options for this: 1) i need to return these leaked connections to pool after some time. 2) Need to find leak in which DAO method.

            but always DestroyCount should show as zero (its my own requirement).

            i have checked with debug="true" and ccm="true" and track-statements set to true . but in my server.log is not showing these connection leak. its only shows statement.close() and resultset.close() suggestions but not about session.close() suggestions.

             

            sample DAO method :

             

            public Emp findById(Long id) throws DAOException {

                    Session session = null;

                    try {

                        session = HibernateConnector.getInstance().getSession();

                        Query query = session.createQuery("from Emp where id = :id");

                        query.setParameter("id", "" + id);

                        List queryList = query.list();

                        if(queryList.isEmpty()) {

                            return null;

                        }

                        return (Emp) queryList.get(0); // only one expected because of

                                                           // the unique id

                    } catch (HibernateException ex) {

                              ex.printStackTrace();

                    } finally {

                        if(session != null) {

                            try {

                                session.close(); // if not put this statement, connection get into leak.(i have forgot these statement in some DAO methods)

                            } catch (HibernateException ignore) {

                            }

                        }

                    }// try/catch/finally ..

                }

             

            please help me.

             

            Thanks in advance.

            • 3. Re: sleeped connections return to pool after some time in jboss as 7.1
              Wolf-Dieter Fink Master

              There is no option to return connections to the pool other than closing it.

               

              I'm not sure why setting the cache-connection-manager to debug the connection is not showing the stacktrace where the connection is opened.

              If the container finish the invocation you should see a message that you should close the connection and the stacktrace.

               

              I'm not a hibernate expert, but if you see the pool statistic hibernate should use this pool.

              Do you have an extended persistence context in some cases?

              • 4. Re: sleeped connections return to pool after some time in jboss as 7.1
                Ramesh Chokkapu Newbie

                Thank You for Reply.

                 

                i am not using extended persistence context. No transations are maintained and using only stateless session beans which are  Bean Managed.