{"id":19011412,"date":"2026-09-04T08:44:25","date_gmt":"2026-09-04T08:44:25","guid":{"rendered":"https:\/\/wordpress.org\/support\/?post_type=topic&#038;p=19011412"},"modified":"2026-09-04T08:47:46","modified_gmt":"2026-09-04T08:47:46","slug":"database-connection-issue-after-clearing-the-top-10-cache","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/database-connection-issue-after-clearing-the-top-10-cache\/","title":{"rendered":"Database connection issue after clearing the Top 10 cache"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am reporting a database connection failure that appears to be related to the daily popular-post query generated by the Top 10 plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Environment:<\/p>\n\n\n\n<ul>\n<li>WebberZone Top 10: 4.4.3<\/li>\n\n\n\n<li>WordPress: 7.1<\/li>\n\n\n\n<li>Single-site installation<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Recently, I used \u201cClear cache\u201d on the Top 10 Tools page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shortly afterward, the entire site began returning database connection errors. Database activity records from the incident showed that the number of stalled connections had reached the server-side limit of 100.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All of the stalled SQL statements that could be identified had the following general form:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SELECT wp_posts.*,<br \/>wp_top_ten_daily.postnumber,<br \/>SUM(wp_top_ten_daily.cntaccess) AS visits,<br \/>\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The complete SQL statement was not available.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I temporarily stopped dynamic WordPress requests and switched the site to a static maintenance page. The site subsequently recovered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There was also an increase in incoming traffic during the incident. However, I cannot determine whether the traffic increase was the initial cause or whether it merely amplified an existing query backlog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As far as I can remember, I have rarely, if ever, used the Top 10 cache-clear function before. Given the timing and the repeated execution of the same daily aggregation query, I wonder whether clearing the cache may have triggered a cache-stampede-like situation, with multiple requests executing the same query concurrently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I would appreciate your thoughts on whether this is a plausible explanation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I also reviewed the version 4.4.3 code and noticed the following:<\/p>\n\n\n\n<ul>\n<li><code>Cache::get_key()<\/code> appears to return a cache key consisting only of an MD5 hash.<\/li>\n\n\n\n<li><code>Cache::get_widget_keys()<\/code> searches for transients whose names begin with <code>_transient_tptn_<\/code>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Is the \u201cClear cache\u201d operation also intended to delete the current transients that use MD5-based keys?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I would also appreciate any information about whether popular-post cache regeneration currently includes locking or single-flight protection to prevent duplicate execution of the same query, and whether any related changes are planned.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"template":"","class_list":["post-19011412","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19011412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19011412\/revisions"}],"predecessor-version":[{"id":19011414,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19011412\/revisions\/19011414"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19011412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}