6288 — 2012-05-17T11:57:08-04:00 — #1
Hello, this is my first post, thank you for any help you can offer!
Some background: I manage and host just over 20 WordPress websites on a managed VPS from a reputable hosting provider. The VPS has 1 GB ram and I believe it's powerful enough to host these sites (my host says so as well), they are generally low traffic in the overall scheme of things.
Checking the error_log file in public_html, I'm seeing many error entries, most go like this:
[16-May-2012 08:30:46] WordPress database error MySQL server has gone away for query SELECT.....and then it's related to a plugin or general WordPress functions.
I try to keep my plugin use to a minimum and the plugins I use are pretty standard. The other interesting thing is that I manage a couple other WordPress sites that are hosted on shared hosting with other companies, I'm not seeing these errors on those sites.
I'm pretty sure all these database errors are affecting the load speed and overall speed of these sites. I've done some research online and seen suggested fixes of modifying wp-db.php file, but this would be very inconvenient on 20+ sites and every WordPress update. I've contacted my host and they've adjusted some settings like max_user_connections and wait_timeout. Some of their final advice was "I think that consulting with a qualified DBA to optimize slow queries and the overall database performance would return better results."
It seems like hosting about 20 relatively low volume WordPress based sites should be manageable with a good VPS (and I'm open to upgrading the RAM or to their next level of hosting). Do I really need to hire a DBA or do you think I need to push my host more to help me?
I'll attach a screenshot showing some server statistics from the past 30 days.
Additional stats, but only 1 day time frame:
lawstevefthit — 2012-05-17T13:32:29-04:00 — #2
with word press i always keep backup files for ftp that way when wp goes to sh*t then i just reupload the latest files that i know worked
spacephoenix — 2012-05-18T02:51:19-04:00 — #3
Is it always the same query? If it is search you code for the file that the query is in, that should identify if it's a main part or a plug-in. Are all occurances of the wordpress core and any plug-ins up to date?
6288 — 2012-05-18T08:33:56-04:00 — #4
I do keep all the sites up to date, both the WordPress core and plugins. It's not the same query, it's everything from plugins to what looks like basic WordPress functions.
For instance, this looks related to basic WordPress navigations:
[17-May-2012 11:36:57] WordPress database error MySQL server has gone away for query SELECT t., tt. FROM hmj_terms AS t INNER JOIN hmj_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'nav_menu' AND t.name = '14' LIMIT 1 made by require, require_once, include, get_header, locate_template, load_template, require_once, wp_nav_menu, wp_get_nav_menu_object, get_term_by
And then I think this is plugin (WooCommerce) related:
[17-May-2012 11:36:56] WordPress database error MySQL server has gone away for query SELECT * FROM hmj_woocommerce_attribute_taxonomies; made by require, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, do_action_ref_array, call_user_func_array, WC_Query->pre_get_posts, Woocommerce->get_attribute_taxonomy_names, Woocommerce->get_attribute_taxonomies
btrivers — 2012-06-10T11:41:53-04:00 — #5
I'm having what appears to be the same problem - I have a single site set up on a HostGator VPS server. The site has a reservation system plugin I wrote that is very system intensive (CPU, queries, etc.). It is only recently that this problem started - June 9, 2012. I did update some plugins, but not sure it is related to that. My other sites on HostGator shared hosting (reseller plan) don't seem to have this issue.
I'm going to try the solution that requires editing /wp-includes/wp-db.php to increase the query wait_timeout, but I agree that this hack is not sustainable long term (http://thesocialmediaguide.com/wordpress-blog/solution-for-wordpress-database-error-mysql-server-has-gone-away-for-query) - at least it would only be this site.
btrivers — 2012-06-10T11:48:11-04:00 — #6
I just found a response to this post - http://www.wptavern.com/forum/plugins-hacks/1343-old-issue-server-has-gone-away-query.html - from Otto who is a trusted WordPress developer / expert. I think that my problem is likely "Seriously overloaded database server.". Not sure if the wp-db.php hack will help in this case. It is quite possible I've mis-configured the VPS too since I don't set them up very often.
"MySQL server has gone away" is a generic error. It happens when the connection between the site and the database times out and the connection auto-closes.
Primary cause: Seriously overloaded database server.
Secondary cause: The mysql server restarted, killing all current connections in the process.
Other possible causes:
- Stupid configuration. Usually due to stupid sysadmin.
- You sent a query that was too large. The default max query size is 1 MB, so this is unlikely.
- DNS failure. mysql relies on name resolution, it can't tell the difference between network timeout and DNS being borked.
- mysql bug. Not uncommon, but rare to see in real life usage.
- Your tables got horked up in a way that actually crashes mysql when it tries to access them. Rare, but possible.