I have an internal database system that sees a lot of activity. For
some reason, certain uses of the connection to this database results
in sleeping connections that persist indefinitely.
The clients are running Windows 2k, Java 5, MySQL J/Connector 3.1.6
The server is running RedHat 8, MySQL 4.1
One particular process uses a windows scheduled task to run a java
application (it's an ugly setup) every 5 minutes if it is not already
running. This task is actually a batch file with a java command that
creates two pooled connections to the database, does some puts and
gets, and exits. It is this specific task that generates the sleeping
connections
mysql> show processlist;
+-------+------------+--------------------+---------+---------+------+-------+-------------------+
| Id | User | Host | db | Command | Time |
State | Info |
+-------+------------+--------------------+---------+---------+------+-------+-------------------+
| 32910 | production | 192.168.1.11:4248 | profile | Sleep | 2166 |
| NULL |
| 32911 | production | 192.168.1.11:4249 | profile | Sleep | 2169 |
| NULL |
| 32912 | production | 192.168.1.11:4256 | profile | Sleep | 2160 |
| NULL |
| 32913 | production | 192.168.1.11:4257 | profile | Sleep | 2162 |
| NULL |
| 32914 | production | 192.168.1.11:4262 | profile | Sleep | 2152 |
| NULL |
| 32915 | production | 192.168.1.11:4263 | profile | Sleep | 2154 |
| NULL |
| 32916 | production | 192.168.1.11:4270 | profile | Sleep | 2144 |
| NULL |
| 32917 | production | 192.168.1.11:4271 | profile | Sleep | 2149 |
| NULL |
| 32918 | production | 192.168.1.11:4278 | profile | Sleep | 2007 |
| NULL |
| 32919 | production | 192.168.1.11:4279 | profile | Sleep | 2013 |
| NULL |
| 32920 | production | 192.168.1.11:4287 | profile | Sleep | 1996 |
| NULL |
| 32921 | production | 192.168.1.11:4288 | profile | Sleep | 1996 |
| NULL |
| 32922 | production | 192.168.1.11:4296 | profile | Sleep | 1931 |
| NULL |
| 32923 | production | 192.168.1.11:4297 | profile | Sleep | 1933 |
| NULL |
| 32924 | production | 192.168.1.11:4304 | profile | Sleep | 1860 |
| NULL |
| 32925 | production | 192.168.1.11:4305 | profile | Sleep | 1890 |
| NULL |
| 32929 | production | 192.168.1.11:4312 | profile | Sleep | 1846 |
| NULL |
| 32930 | production | 192.168.1.11:4313 | profile | Sleep | 1857 |
| NULL |
| 32931 | production | 192.168.1.11:4320 | profile | Sleep | 1797 |
| NULL |
| 32932 | production | 192.168.1.11:4321 | profile | Sleep | 1802 |
| NULL |
My question is this:
How can I configure MySQL or J/Connector to automatically terminate
connections that sleep more than some threshold?
Optionally:
How can I further debug these sleeping connections? Is there a way to
get more detail on what any MySQL connection has been doing before it
went to sleep? |