Topic on Project:Support desk

Won't Access Database: Too many open links

9
210.56.82.86 (talkcontribs)

"DB connection error: :real_connect(): Too many open links (1)"

I believe the problem is number of connections MediaWiki is required to open.

My server admin says for security reasons I need to find out how many MediaWiki requires?

http://www.solidarity.coop/wiki

88.130.115.61 (talkcontribs)

If this is about the number of DB connections, which MediaWiki needs to open, then this depends on the number of concurrent visitors to your wiki. You might start with something like 25 and go higher, should you need more.

Which versions of PHP and MySQL are you using? PHP before 5.3.3 had a bug[1] which made it create "zombie connections". These then slowly filled up ressources until the DB was no longer reachable.

[1] https://bugs.php.net/bug.php?id=51605

210.56.82.86 (talkcontribs)

PHP Version 5.3.29

210.56.82.86 (talkcontribs)

Provider won't increase connections above 20. So I don't think I can install.

88.130.100.37 (talkcontribs)

The default for max_conections was 100 and in current MySQL versions is 151 . So only having 20 is ... kind of lame. Anyway, when you say that installation does not even work, then at that moment you are not using 20 connections, but you are trying to use exactly one connection and not more. I know of a wiki, which is used more or less frequently and there something like 25 connections is enough to serve all visitors. If you cannot even make one single connection to MySQL, then this effectively means that MySQL is not usable for you on this server. MediaWiki (and also many other nice systems) won't work without database access. If the host cannot fix his setup, then I would change to a host, where you actually can use what you paid for.

210.56.87.187 (talkcontribs)

Hi Steve,

TPP Wholesale MySQL servers have a "20 concurrent connections" limit per MySQL user to prevent heavy MySQL load on the server and to identify scripts that use unnecessary MySQL connections due to bad coding practices.

These errors can be prevented by making some tweaks in your code:

1. Use of mysql_connect() for connections to MySQL databases in your code. The advantage is the link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close(). A detailed explanation can be found at http://us3.php.net/manual/en/function.mysql-connect.php

2. Use of mysql_close() explicitly. Although mysql_connect() closes the connections, use of mysql_close() in conjunction with it would make sure that the connection is totally closed.

3. Prevent use of mysql_pconnect(). The disadvantage is the connection to the MySQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use. Please note: mysql_close() will not close links established by mysql_pconnect.

Please take note of the following details.

List of files with mysql_pconnect:

soso15411@shell:/clientdata/ap

ache-www/s/o/solidarity.coop/www$ grep -rl mysql_pconnect .
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./mediawiki-back/includes/db/DatabaseMysql.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki-back/includes/db/DatabaseMysql.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki/includes/db/DatabaseMysql.php

Instances of mysql_connect:
/clientdata/apache-www/s/o/solidarity.coop/www$ grep -rl mysql_connect .
./mediawiki-back/netreginstall

/db-util.php
./mediawiki-back/HISTORY
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./mediawiki-back/includes/db/DatabaseMysql.php
./wiki-back/netreginstall/db-util.php
./wiki-back/HISTORY
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki-back/includes/db/DatabaseMysql.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki/includes/db/DatabaseMysqli.php
./wiki/includes/db/DatabaseMysql.php
./wiki/HISTORY

Instances of mysql_close:
grep -rl mysql_pconnect .
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./mediawiki-back/includes/db/DatabaseMysql.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
aarney@shell:~$ setdomain solidarity.coop
soso15411@shell:/clientdata/apache-www/s/o/solidarity.coop/www$ grep -rl mysql_close .
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./mediawiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./mediawiki-back/includes/db/DatabaseMysql.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki-back/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki-back/includes/db/DatabaseMysql.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
./wiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
./wiki/includes/db/DatabaseMysql.php

Unfortunately, I cannot make any changes to this number, and it is most likely something you should take up with the mediawiki developers as this is an issue with the way the site is coded.

Kind Regards, Alex

TPP Wholesale Support Team

210.56.87.16 (talkcontribs)

Any plans from the Mediawiki team to fix this?

88.130.87.233 (talkcontribs)

The fact that a certain function is present in the code does not tell anything about if and how it's actually used.

It would be important to know when/why this happens. As far as I know the MediaWiki Core and also SyntaxHighlight_GeSHi, which you have on your system (which does not mean you actually use it), do not use more connections than they need. As written above I have a wiki, which is frequently used and for this wiki maybe 30-50 concurrent DB connections are really enough.

Is it possible that you in fact really have a need for more connections? E.g. do you have more than 20 concurrent visitors requesting stuff from MediaWiki? Your access logs should show you that...

Florianschmidtwelzow (talkcontribs)

> E.g. do you have more than 20 concurrent visitors

That in fact isn't a problem, too. MySQL-Connections will be closed as soon as the execution of the script ends. That means, that you need to have more then 20 visitors, who opens your wiki page at the exact same time and the execution of the php script must be at the same time, too, which is really difficult to do (think, that a normal page view, e.g. of Special:NewMessages takes 887 ms). So i would check, if you really have only Syntaxhighlight as an extension and check, if another application also use the same database user and if so, check, if there is a misconfiguration or a problem in the implementation of database access.

Reply to "Won't Access Database: Too many open links"