Hi,
There seems to be a case where a db connection is not released back to the pool, leading to db connection exhaustion within SonarQube.
SonarQube version: 4.5.2
Database: MySQL
db properties:
sonar.jdbc.maxActive=20
sonar.jdbc.maxIdle=5
sonar.jdbc.minIdle=2
sonar.jdbc.maxWait=5000
sonar.jdbc.minEvictableIdleTimeMillis=600000
sonar.jdbc.timeBetweenEvictionRunsMillis=30000
From above, I would conclude that connections can be sleeping for max 629 seconds until they are closed.
Mysql shows connections are sleeping longer than that, hence I conclude connections get lost.
+-----+-------+-----------------+-------+---------+------+-------+-----------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+-------+-----------------+-------+---------+------+-------+-----------------+
| 4 | sonar | localhost:56977 | sonar | Sleep |
1386 | | NULL |
| 6 | sonar | localhost:56979 | sonar | Sleep |
3408 | | NULL |
| 7 | sonar | localhost:56980 | sonar | Sleep |
3200 | | NULL |
| 8 | sonar | localhost:56981 | sonar | Sleep |
3068 | | NULL |
| 114 | sonar | localhost:57603 | sonar | Sleep |
1774 | | NULL |
| 115 | sonar | localhost:57629 | sonar | Sleep |
1602 | | NULL |
| 116 | sonar | localhost:57634 | sonar | Sleep |
1669 | | NULL |
| 117 | sonar | localhost:57703 | sonar | Sleep |
1500 | | NULL |
| 118 | sonar | localhost:57735 | sonar | Sleep |
1417 | | NULL |
| 119 | sonar | localhost:57818 | sonar | Sleep | 545 | | NULL |
| 120 | sonar | localhost:57842 | sonar | Sleep |
807 | | NULL |
| 121 | sonar | localhost:57848 | sonar | Sleep |
1043 | | NULL |
| 122 | sonar | localhost:57959 | sonar | Sleep |
1012 | | NULL |
| 123 | sonar | localhost:57968 | sonar | Sleep |
982 | | NULL |
| 124 | sonar | localhost:58035 | sonar | Sleep |
742 | | NULL |
| 125 | sonar | localhost:58036 | sonar | Sleep |
771 | | NULL |
| 126 | sonar | localhost:58051 | sonar | Sleep | 34 | | NULL |
| 127 | sonar | localhost:58052 | sonar | Sleep |
713 | | NULL |
| 128 | sonar | localhost:58059 | sonar | Sleep |
668 | | NULL |
| 136 | sonar | localhost:58119 | sonar | Sleep | 409 | | NULL |
+-----+-------+-----------------+-------+---------+------+-------+-------------
For all of the lost connections, this is the last query executed (with id being variable):
Query SELECT * FROM `projects` WHERE (`projects`.`id` = 93653) LIMIT 1
So wherever this happens, I think the connection is not closed, thereby not returning the connection to the pool.
I haven't found a related JIRA incident, nor find a fix for the above in the release history of newer versions.
This topic on SO might be the same issue or related:
http://stackoverflow.com/questions/25690194/sonarqube-4-3-2-not-releasing-oracle-db-connectionsIf needed, I can provide all the queries executed on the connections to trace where it happens.
I suspect somewhere in a flow where a user deletes a project through the web interface.