MySQL connection not closing?

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Registered User
Posts: 86
Joined: Wed Oct 01, 2008 7:15 pm

MySQL connection not closing?

Post by mtridersclb » Wed May 04, 2011 4:32 pm

Support Request Template
What version of phpBB are you using? phpBB 3.0.8
What is your board's URL?
Who do you host your board with?
How did you install your board? I used the download package from
Is your board a fresh install or a conversion? Update from a previous version of phpBB3
Do you have any MODs installed? Yes
Is registration required to reproduce this issue? No
What version of phpBB3 did you update from? phpBB 3.0.7
What MODs do you have installed? Shmoogle
What styles do you currently have installed? No answer given
What language(s) is your board currently using? English
Which database type/version are you using? MySQL 4
What is your level of experience? Comfortable with PHP and phpBB
When did your problem begin? It's got progressively worse over the past couple of months.
Please describe your problem. The board is making too many connections to the database so that it's considered to be using an unfair amount of server resources and has been suspended.

The host claims the forum software does not close the MySQL connection after each run of the script. So how do I do that?

They have provided us with a log of events which doesn't really say much. here's an example:

[root@cpanel15 ~]# ps auxw | grep username
username 12171 0.0 0.2 34824 16936 ? S May03 0:00 /usr/bin/php /home/username/public_html/MTRC/search.php
username 12330 0.0 0.2 34776 16868 ? S May03 0:00 /usr/bin/php /home/username/public_html/MTRC/search.php
username 15315 0.0 0.2 40584 20796 ? S May03 0:00 /usr/bin/php /home/username/public_html/MTRC/posting.php
username 15330 0.0 0.2 35052 16660 ? S May03 0:00 /usr/bin/php /home/username/public_html/MTRC/viewtopic.php
username 15336 0.0 0.2 34536 16940 ? S May03 0:00 /usr/bin/php /home/username/public_html/MTRC/viewtopic.php
... etc

49269 username_phpb1 localhost username_phpb1 Query 37362 Copying to tmp table SELECT p.post_id FROM (phpbb_search_wordmatch m1, phpbb_search_wordmatch m2, phpbb_search_wordmatch
49312 username_phpb1 localhost username_phpb1 Query 37284 Copying to tmp table SELECT p.post_id FROM (phpbb_search_wordmatch m1, phpbb_search_wordmatch m2, phpbb_search_wordmatch
50176 username_phpb1 localhost username_phpb1 Query 36318 Locked UPDATE phpbb_posts\n\t\t\tSET post_edit_reason = '', forum_id = 24, poster_id = 94, icon_id = 0, post_ap
50179 username_phpb1 localhost username_phpb1 Query 36305 Locked SELECT t.*, f.*, p.post_approved FROM (phpbb_forums f, phpbb_posts p, phpbb_topics t) WHERE p.post_i
50182 username_phpb1 localhost username_phpb1 Query 36300 Locked SELECT p.post_id\n\tFROM phpbb_posts p\n\tWHERE p.topic_id = 8550\n\t\tAND p.post_approved = 1\n\t\t\n\t\t\n\tORDER
50184 username_phpb1 localhost username_phpb1 Query 36297 Locked SELECT p.post_id\n\tFROM phpbb_posts p\n\tWHERE p.topic_id = 8421\n\t\tAND p.post_approved = 1\n\t\t\n\t\t\n\tORDER
... etc

Thanks :)

Generated by SRT Generator ($Rev: 4778 $)
Last edited by Pit$Bull on Thu May 05, 2011 4:50 pm, edited 1 time in total.
Reason: Topic icon changed

User avatar
Former Team Member
Posts: 7022
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: MySQL connection not closing?

Post by tbackoff » Thu May 05, 2011 1:50 am

Call their bluff.

Code: Select all

* Closing the cache object and the database
* Cool function name, eh? We might want to add operations to it later
function garbage_collection()
	global $cache, $db;

	// Unload cache, must be done before the DB connection if closed
	if (!empty($cache))

	// Close our DB connection.
	if (!empty($db))
That function closes database connections at the end of each script and is called in the function above that (page_footer()). The page_footer() function is called in every page (index.php, viewforum.php, viewtopic,php, etc).
Flying is the second best thrill to cheerleaders; being caught is the first.

Former Team Member
Posts: 1221
Joined: Sat Jan 30, 2010 4:42 pm
Location: NYC

Re: MySQL connection not closing?

Post by Oleg » Thu May 05, 2011 5:15 am

From the output that the host supplied, you do not have sufficient database resources for your board. Specifically the search queries are giving their database a good workout.

This could be due to users entering many search terms, wildcards, etc. or the host misconfiguring their databases or simply not having sufficient hardware resources.

Unfortunately phpbb search may be resource intensive. If your host does not give you adequate resources to handle demands imposed by phpbb and/or your users you may need to move to another host.
Participate in phpBB development: Get involved | Issue tracker | Report a bug | Development board | [url=irc://]Development IRC chat[/url]
My stuff:

Registered User
Posts: 86
Joined: Wed Oct 01, 2008 7:15 pm

Re: MySQL connection not closing?

Post by mtridersclb » Thu May 05, 2011 4:35 pm

Thanks to you both,
I'll try reconfiguring the search settings to see if that helps.



Return to “[3.0.x] Support Forum”