Hibernate plugin connections create 2 connection per database update but never removes them.

      Hibernate session is not close.

      Hibernate configuration:

              <property name="c3p0.max_size">10</property>
              <property name="c3p0.min_size">2</property>
              <property name="c3p0.timeout">1800</property>
              <property name="c3p0.max_statements">50</property>
              <property name="connection.autocommit">true</property>
      

      The problem is that max connections overrides defined value in hibernate (10) I have 12 (If I continue I have 2 connection for each register Job...). Every new Job registered with Audit2db retrieves 2 new connections.

      $ echo "SHOW PROCESSLIST" | mysql --user=jenkins --password=jenkins
      Id	User	Host	db	Command	Time	State	Info
      109	jenkins	localhost:48405	jenkinsdb	Sleep	299		NULL
      110	jenkins	localhost:48407	jenkinsdb	Sleep	1014		NULL
      111	jenkins	localhost:48408	jenkinsdb	Sleep	1014		NULL
      114	jenkins	localhost:48409	jenkinsdb	Sleep	241		NULL
      117	jenkins	localhost:48422	jenkinsdb	Sleep	235		NULL
      118	jenkins	localhost:48421	jenkinsdb	Sleep	2247		NULL
      131	jenkins	localhost:48438	jenkinsdb	Sleep	1921		NULL
      132	jenkins	localhost:48437	jenkinsdb	Sleep	1921		NULL
      133	jenkins	localhost:48440	jenkinsdb	Sleep	1914		NULL
      134	jenkins	localhost:48441	jenkinsdb	Sleep	1917		NULL
      152	jenkins	localhost:48459	jenkinsdb	Sleep	231		NULL
      153	jenkins	localhost:48460	jenkinsdb	Sleep	231		NULL
      157	jenkins	localhost:48461	jenkinsdb	Sleep	78		NULL
      158	jenkins	localhost:48462	jenkinsdb	Sleep	53		NULL
      159	jenkins	localhost	NULL	Query	0	NULL	SHOW PROCESSLIST
      

      The value representig timeout 1800 (secs) doesn't remove sleep connections.

      I think there is another value like `idle_test_period` that hast to be set (if I've understood the meaning) to remove idle connections.

      Or the problem is that hibernate connections have never been closed

      Thanks!

          [JENKINS-21058] Close sleep connections

          Test

          I've created a branch for the plugin to solve the issue because nobody is having responsability of the plugin for years

          What' should I do for release the plugin and test it on cloudbees environment ?
          thanks a lot !

          Ricardo García Fernández added a comment - Test I've created a branch for the plugin to solve the issue because nobody is having responsability of the plugin for years https://github.com/ricardogarfe/audit2db-plugin/tree/close_db_connections What' should I do for release the plugin and test it on cloudbees environment ? thanks a lot !

          Configuration

          I've configured correctly c3p0 values in hibernate.cfg.xml file:

          And make a pull request to base repository

          I've tested connections during three days and thera are only 4 connections idle instead of more than 20...

          Ricardo García Fernández added a comment - Configuration I've configured correctly c3p0 values in hibernate.cfg.xml file: https://github.com/ricardogarfe/audit2db-plugin/commit/2dccc21102f5f7ef8ac79eb823d1844a805d406d And make a pull request to base repository https://github.com/jenkinsci/audit2db-plugin/pull/14 I've tested connections during three days and thera are only 4 connections idle instead of more than 20...

            ricardogarfe Ricardo García Fernández
            ricardogarfe Ricardo García Fernández
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: