Too Many Connections

I found that after a few minutes of playing with RT the layout broke and
then I started getting 500 Internal Server Errors:

[Thu Nov 28 14:21:48 2002] [warning]:
DBI->connect(dbname=rt3;host=localhost) failed: Too many connections at
/usr/local/share/perl/5.6.1/DBIx/SearchBuilder/Handle.pm line 119
(/opt/rt3/lib/RT.pm:220)
[Fri Nov 29 01:21:48 2002] [error] Connect Failed Too many connections
at /opt/rt3/lib/RT.pm line 122

Turns out that MySQL had accrued heaps of connections (as per
processlist following). I’m running RT 2.1.51 on Debian GNU/Linux 3.0
with Apache 1.3.26-0woody1 and mod_perl 1.26-3.0woody1. My apache.conf
(included in httpd.conf) contains:

*<VirtualHost 1.2.3.4:80>
DocumentRoot /opt/rt3/share/html
ServerName mybox.mydomain.com
PerlRequire /opt/rt3/bin/webmux.pl

SetHandler perl-script
PerlHandler RT::Mason


I’m going to have a stab in the dark and try adding:

PerlModule Apache::DBI
PerlFreshRestart On

mysqladmin -u root -p processlist
Enter password:
| Id | User | Host | db | Command | Time | State |
Info |
| 25 | rt_user | localhost | rt3 | Sleep | 4303 |
| |
| 26 | rt_user | localhost | rt3 | Sleep | 4303 |
| |
| 30 | rt_user | localhost | rt3 | Sleep | 4202 |
| |
| 31 | rt_user | localhost | rt3 | Sleep | 4202 |
| |
| 33 | rt_user | localhost | rt3 | Sleep | 3813 |
| |
| 34 | rt_user | localhost | rt3 | Sleep | 3813 |
| |
| 36 | rt_user | localhost | rt3 | Sleep | 3810 |
| |
| 37 | rt_user | localhost | rt3 | Sleep | 3810 |
| |
| 39 | rt_user | localhost | rt3 | Sleep | 3789 |
| |
| 40 | rt_user | localhost | rt3 | Sleep | 3789 |
| |
| 42 | rt_user | localhost | rt3 | Sleep | 3782 |
| |
| 43 | rt_user | localhost | rt3 | Sleep | 3782 |
| |
| 45 | rt_user | localhost | rt3 | Sleep | 3779 |
| |
| 46 | rt_user | localhost | rt3 | Sleep | 3779 |
| |
| 47 | rt_user | localhost | rt3 | Sleep | 3770 |
| |
| 48 | rt_user | localhost | rt3 | Sleep | 3770 |
| |
| 50 | rt_user | localhost | rt3 | Sleep | 3757 |
| |
| 51 | rt_user | localhost | rt3 | Sleep | 3757 |
| |
| 53 | rt_user | localhost | rt3 | Sleep | 3754 |
| |
| 54 | rt_user | localhost | rt3 | Sleep | 3753 |
| |
| 56 | rt_user | localhost | rt3 | Sleep | 3751 |
| |
| 57 | rt_user | localhost | rt3 | Sleep | 3751 |
| |
| 59 | rt_user | localhost | rt3 | Sleep | 3743 |
| |
| 60 | rt_user | localhost | rt3 | Sleep | 3743 |
| |
| 61 | rt_user | localhost | rt3 | Sleep | 3739 |
| |
| 62 | rt_user | localhost | rt3 | Sleep | 3739 |
| |
| 64 | rt_user | localhost | rt3 | Sleep | 3737 |
| |
| 65 | rt_user | localhost | rt3 | Sleep | 3736 |
| |
| 67 | rt_user | localhost | rt3 | Sleep | 3735 |
| |
| 68 | rt_user | localhost | rt3 | Sleep | 3735 |
| |
| 70 | rt_user | localhost | rt3 | Sleep | 3732 |
| |
| 71 | rt_user | localhost | rt3 | Sleep | 3732 |
| |
| 72 | rt_user | localhost | rt3 | Sleep | 3729 |
| |
| 73 | rt_user | localhost | rt3 | Sleep | 3729 |
| |
| 75 | rt_user | localhost | rt3 | Sleep | 3727 |
| |
| 76 | rt_user | localhost | rt3 | Sleep | 3727 |
| |
| 78 | rt_user | localhost | rt3 | Sleep | 3724 |
| |
| 79 | rt_user | localhost | rt3 | Sleep | 3724 |
| |
| 80 | rt_user | localhost | rt3 | Sleep | 3718 |
| |
| 81 | rt_user | localhost | rt3 | Sleep | 3718 |
| |
| 82 | rt_user | localhost | rt3 | Sleep | 1843 |
| |
| 83 | rt_user | localhost | rt3 | Sleep | 1843 |
| |
| 85 | rt_user | localhost | rt3 | Sleep | 1835 |
| |
| 86 | rt_user | localhost | rt3 | Sleep | 1834 |
| |
| 87 | rt_user | localhost | rt3 | Sleep | 1830 |
| |
| 88 | rt_user | localhost | rt3 | Sleep | 1829 |
| |
| 89 | rt_user | localhost | rt3 | Sleep | 1782 |
| |
| 90 | rt_user | localhost | rt3 | Sleep | 1782 |
| |
| 92 | rt_user | localhost | rt3 | Sleep | 1777 |
| |
| 93 | rt_user | localhost | rt3 | Sleep | 1777 |
| |
| 95 | rt_user | localhost | rt3 | Sleep | 1579 |
| |
| 96 | rt_user | localhost | rt3 | Sleep | 1578 |
| |
| 98 | rt_user | localhost | rt3 | Sleep | 1575 |
| |
| 99 | rt_user | localhost | rt3 | Sleep | 1575 |
| |
| 100 | rt_user | localhost | rt3 | Sleep | 1570 |
| |
| 101 | rt_user | localhost | rt3 | Sleep | 1570 |
| |
| 102 | rt_user | localhost | rt3 | Sleep | 1548 |
| |
| 103 | rt_user | localhost | rt3 | Sleep | 1548 |
| |
| 105 | rt_user | localhost | rt3 | Sleep | 1542 |
| |
| 106 | rt_user | localhost | rt3 | Sleep | 1542 |
| |
| 107 | rt_user | localhost | rt3 | Sleep | 1538 |
| |
| 108 | rt_user | localhost | rt3 | Sleep | 1538 |
| |
| 109 | rt_user | localhost | rt3 | Sleep | 1511 |
| |
| 110 | rt_user | localhost | rt3 | Sleep | 1511 |
| |
| 112 | rt_user | localhost | rt3 | Sleep | 1509 |
| |
| 113 | rt_user | localhost | rt3 | Sleep | 1509 |
| |
| 114 | rt_user | localhost | rt3 | Sleep | 1507 |
| |
| 115 | rt_user | localhost | rt3 | Sleep | 1507 |
| |
| 117 | rt_user | localhost | rt3 | Sleep | 1486 |
| |
| 118 | rt_user | localhost | rt3 | Sleep | 1486 |
| |
| 120 | rt_user | localhost | rt3 | Sleep | 1464 |
| |
| 121 | rt_user | localhost | rt3 | Sleep | 1464 |
| |
| 122 | rt_user | localhost | rt3 | Sleep | 1458 |
| |
| 123 | rt_user | localhost | rt3 | Sleep | 1457 |
| |
| 125 | rt_user | localhost | rt3 | Sleep | 1455 |
| |
| 126 | rt_user | localhost | rt3 | Sleep | 1455 |
| |
| 128 | rt_user | localhost | rt3 | Sleep | 1453 |
| |
| 129 | rt_user | localhost | rt3 | Sleep | 1453 |
| |
| 131 | rt_user | localhost | rt3 | Sleep | 1451 |
| |
| 132 | rt_user | localhost | rt3 | Sleep | 1451 |
| |
| 134 | rt_user | localhost | rt3 | Sleep | 1448 |
| |
| 135 | rt_user | localhost | rt3 | Sleep | 1448 |
| |
| 136 | rt_user | localhost | rt3 | Sleep | 1409 |
| |
| 137 | rt_user | localhost | rt3 | Sleep | 1409 |
| |
| 138 | rt_user | localhost | rt3 | Sleep | 1298 |
| |
| 139 | rt_user | localhost | rt3 | Sleep | 1298 |
| |
| 141 | rt_user | localhost | rt3 | Sleep | 1295 |
| |
| 142 | rt_user | localhost | rt3 | Sleep | 1295 |
| |
| 143 | rt_user | localhost | rt3 | Sleep | 628 |
| |
| 144 | rt_user | localhost | rt3 | Sleep | 627 |
| |
| 145 | rt_user | localhost | rt3 | Sleep | 416 |
| |
| 146 | rt_user | localhost | rt3 | Sleep | 416 |
| |
| 148 | rt_user | localhost | rt3 | Sleep | 408 |
| |
| 149 | rt_user | localhost | rt3 | Sleep | 408 |
| |
| 151 | rt_user | localhost | rt3 | Sleep | 404 |
| |
| 152 | rt_user | localhost | rt3 | Sleep | 404 |
| |
| 153 | rt_user | localhost | rt3 | Sleep | 402 |
| |
| 154 | rt_user | localhost | rt3 | Sleep | 402 |
| |
| 155 | rt_user | localhost | rt3 | Sleep | 389 |
| |
| 161 | root | localhost | | Query | 0 | | show
processlist |

you’ve configured your apache to spawn more children than you’ve told
your database to create.On Thu, Nov 28, 2002 at 03:54:08PM +1100, Sam Johnston wrote:

I found that after a few minutes of playing with RT the layout broke and
then I started getting 500 Internal Server Errors:

[Thu Nov 28 14:21:48 2002] [warning]:
DBI->connect(dbname=rt3;host=localhost) failed: Too many connections at
/usr/local/share/perl/5.6.1/DBIx/SearchBuilder/Handle.pm line 119
(/opt/rt3/lib/RT.pm:220)
[Fri Nov 29 01:21:48 2002] [error] Connect Failed Too many connections
at /opt/rt3/lib/RT.pm line 122

Turns out that MySQL had accrued heaps of connections (as per
processlist following). I’m running RT 2.1.51 on Debian GNU/Linux 3.0
with Apache 1.3.26-0woody1 and mod_perl 1.26-3.0woody1. My apache.conf
(included in httpd.conf) contains:

*<VirtualHost 1.2.3.4:80>
DocumentRoot /opt/rt3/share/html
ServerName mybox.mydomain.com
PerlRequire /opt/rt3/bin/webmux.pl

SetHandler perl-script
PerlHandler RT::Mason


*
I’m going to have a stab in the dark and try adding:

PerlModule Apache::DBI
PerlFreshRestart On

mysqladmin -u root -p processlist
Enter password:
±----±--------±----------±----±--------±-----±------±-----------------+
| Id | User | Host | db | Command | Time | State |
Info |
±----±--------±----------±----±--------±-----±------±-----------------+
| 25 | rt_user | localhost | rt3 | Sleep | 4303 |
| |
| 26 | rt_user | localhost | rt3 | Sleep | 4303 |
| |
| 30 | rt_user | localhost | rt3 | Sleep | 4202 |
| |
| 31 | rt_user | localhost | rt3 | Sleep | 4202 |
| |
| 33 | rt_user | localhost | rt3 | Sleep | 3813 |
| |
| 34 | rt_user | localhost | rt3 | Sleep | 3813 |
| |
| 36 | rt_user | localhost | rt3 | Sleep | 3810 |
| |
| 37 | rt_user | localhost | rt3 | Sleep | 3810 |
| |
| 39 | rt_user | localhost | rt3 | Sleep | 3789 |
| |
| 40 | rt_user | localhost | rt3 | Sleep | 3789 |
| |
| 42 | rt_user | localhost | rt3 | Sleep | 3782 |
| |
| 43 | rt_user | localhost | rt3 | Sleep | 3782 |
| |
| 45 | rt_user | localhost | rt3 | Sleep | 3779 |
| |
| 46 | rt_user | localhost | rt3 | Sleep | 3779 |
| |
| 47 | rt_user | localhost | rt3 | Sleep | 3770 |
| |
| 48 | rt_user | localhost | rt3 | Sleep | 3770 |
| |
| 50 | rt_user | localhost | rt3 | Sleep | 3757 |
| |
| 51 | rt_user | localhost | rt3 | Sleep | 3757 |
| |
| 53 | rt_user | localhost | rt3 | Sleep | 3754 |
| |
| 54 | rt_user | localhost | rt3 | Sleep | 3753 |
| |
| 56 | rt_user | localhost | rt3 | Sleep | 3751 |
| |
| 57 | rt_user | localhost | rt3 | Sleep | 3751 |
| |
| 59 | rt_user | localhost | rt3 | Sleep | 3743 |
| |
| 60 | rt_user | localhost | rt3 | Sleep | 3743 |
| |
| 61 | rt_user | localhost | rt3 | Sleep | 3739 |
| |
| 62 | rt_user | localhost | rt3 | Sleep | 3739 |
| |
| 64 | rt_user | localhost | rt3 | Sleep | 3737 |
| |
| 65 | rt_user | localhost | rt3 | Sleep | 3736 |
| |
| 67 | rt_user | localhost | rt3 | Sleep | 3735 |
| |
| 68 | rt_user | localhost | rt3 | Sleep | 3735 |
| |
| 70 | rt_user | localhost | rt3 | Sleep | 3732 |
| |
| 71 | rt_user | localhost | rt3 | Sleep | 3732 |
| |
| 72 | rt_user | localhost | rt3 | Sleep | 3729 |
| |
| 73 | rt_user | localhost | rt3 | Sleep | 3729 |
| |
| 75 | rt_user | localhost | rt3 | Sleep | 3727 |
| |
| 76 | rt_user | localhost | rt3 | Sleep | 3727 |
| |
| 78 | rt_user | localhost | rt3 | Sleep | 3724 |
| |
| 79 | rt_user | localhost | rt3 | Sleep | 3724 |
| |
| 80 | rt_user | localhost | rt3 | Sleep | 3718 |
| |
| 81 | rt_user | localhost | rt3 | Sleep | 3718 |
| |
| 82 | rt_user | localhost | rt3 | Sleep | 1843 |
| |
| 83 | rt_user | localhost | rt3 | Sleep | 1843 |
| |
| 85 | rt_user | localhost | rt3 | Sleep | 1835 |
| |
| 86 | rt_user | localhost | rt3 | Sleep | 1834 |
| |
| 87 | rt_user | localhost | rt3 | Sleep | 1830 |
| |
| 88 | rt_user | localhost | rt3 | Sleep | 1829 |
| |
| 89 | rt_user | localhost | rt3 | Sleep | 1782 |
| |
| 90 | rt_user | localhost | rt3 | Sleep | 1782 |
| |
| 92 | rt_user | localhost | rt3 | Sleep | 1777 |
| |
| 93 | rt_user | localhost | rt3 | Sleep | 1777 |
| |
| 95 | rt_user | localhost | rt3 | Sleep | 1579 |
| |
| 96 | rt_user | localhost | rt3 | Sleep | 1578 |
| |
| 98 | rt_user | localhost | rt3 | Sleep | 1575 |
| |
| 99 | rt_user | localhost | rt3 | Sleep | 1575 |
| |
| 100 | rt_user | localhost | rt3 | Sleep | 1570 |
| |
| 101 | rt_user | localhost | rt3 | Sleep | 1570 |
| |
| 102 | rt_user | localhost | rt3 | Sleep | 1548 |
| |
| 103 | rt_user | localhost | rt3 | Sleep | 1548 |
| |
| 105 | rt_user | localhost | rt3 | Sleep | 1542 |
| |
| 106 | rt_user | localhost | rt3 | Sleep | 1542 |
| |
| 107 | rt_user | localhost | rt3 | Sleep | 1538 |
| |
| 108 | rt_user | localhost | rt3 | Sleep | 1538 |
| |
| 109 | rt_user | localhost | rt3 | Sleep | 1511 |
| |
| 110 | rt_user | localhost | rt3 | Sleep | 1511 |
| |
| 112 | rt_user | localhost | rt3 | Sleep | 1509 |
| |
| 113 | rt_user | localhost | rt3 | Sleep | 1509 |
| |
| 114 | rt_user | localhost | rt3 | Sleep | 1507 |
| |
| 115 | rt_user | localhost | rt3 | Sleep | 1507 |
| |
| 117 | rt_user | localhost | rt3 | Sleep | 1486 |
| |
| 118 | rt_user | localhost | rt3 | Sleep | 1486 |
| |
| 120 | rt_user | localhost | rt3 | Sleep | 1464 |
| |
| 121 | rt_user | localhost | rt3 | Sleep | 1464 |
| |
| 122 | rt_user | localhost | rt3 | Sleep | 1458 |
| |
| 123 | rt_user | localhost | rt3 | Sleep | 1457 |
| |
| 125 | rt_user | localhost | rt3 | Sleep | 1455 |
| |
| 126 | rt_user | localhost | rt3 | Sleep | 1455 |
| |
| 128 | rt_user | localhost | rt3 | Sleep | 1453 |
| |
| 129 | rt_user | localhost | rt3 | Sleep | 1453 |
| |
| 131 | rt_user | localhost | rt3 | Sleep | 1451 |
| |
| 132 | rt_user | localhost | rt3 | Sleep | 1451 |
| |
| 134 | rt_user | localhost | rt3 | Sleep | 1448 |
| |
| 135 | rt_user | localhost | rt3 | Sleep | 1448 |
| |
| 136 | rt_user | localhost | rt3 | Sleep | 1409 |
| |
| 137 | rt_user | localhost | rt3 | Sleep | 1409 |
| |
| 138 | rt_user | localhost | rt3 | Sleep | 1298 |
| |
| 139 | rt_user | localhost | rt3 | Sleep | 1298 |
| |
| 141 | rt_user | localhost | rt3 | Sleep | 1295 |
| |
| 142 | rt_user | localhost | rt3 | Sleep | 1295 |
| |
| 143 | rt_user | localhost | rt3 | Sleep | 628 |
| |
| 144 | rt_user | localhost | rt3 | Sleep | 627 |
| |
| 145 | rt_user | localhost | rt3 | Sleep | 416 |
| |
| 146 | rt_user | localhost | rt3 | Sleep | 416 |
| |
| 148 | rt_user | localhost | rt3 | Sleep | 408 |
| |
| 149 | rt_user | localhost | rt3 | Sleep | 408 |
| |
| 151 | rt_user | localhost | rt3 | Sleep | 404 |
| |
| 152 | rt_user | localhost | rt3 | Sleep | 404 |
| |
| 153 | rt_user | localhost | rt3 | Sleep | 402 |
| |
| 154 | rt_user | localhost | rt3 | Sleep | 402 |
| |
| 155 | rt_user | localhost | rt3 | Sleep | 389 |
| |
| 161 | root | localhost | | Query | 0 | | show
processlist |
±----±--------±----------±----±--------±-----±------±-----------------+


rt-devel mailing list
rt-devel@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-devel

»|« http://www.bestpractical.com/rt – Trouble Ticketing. Free.

Never, ever, use PerlFreshRestart On with anything that runs on HTML::Mason.
You will experience great pain and suffering when strange things start to
happen for no aparent reason.

See the Mason Users mailing list for more info.
http://lists.sourceforge.net/lists/listinfo/mason-users

See also the Mason FAQ:
http://masonhq.com/docs/faq/#i_get_an_error_like_the_followiFrom: Jesse Vincent [mailto:jesse@bestpractical.com]
Sent: Wednesday, November 27, 2002 10:05 PM
To: Sam Johnston
Cc: rt-devel@fsck.com
Subject: Re: [rt-devel] Too Many Connections

you’ve configured your apache to spawn more children than you’ve told
your database to create.

Hi Jesse and all,

this is not Apache problem.
It’s because DBIx::SearchBuilder
does not have DESTROY() method, as described in my
first message ever to this list:From: “Stanislav Sinyagin” ssinyagin@yahoo.com | This is Spam | Add to Address Book
To: rt-devel@lists.fsck.com
Subject: [rt-devel] some patches and wishes: 2.1.39
Date: Tue, 8 Oct 2002 07:04:28 -0700 (PDT)

lib/RT/Handle:

The DBIx-SearchBuilder package available from CPAN is 0.61.
The mysql connections are not cleared, and soon you get
"too many connections" message.
Version 0.73 does not solve the problem
I added DESTROY() handler, and now it’s much better.
Please apply the patch attached, and update CPAN.

Regards,
Stan