{"id":13451315,"date":"2020-09-24T21:03:42","date_gmt":"2020-09-24T21:03:42","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/database-transactions\/"},"modified":"2020-09-24T22:42:17","modified_gmt":"2020-09-24T22:42:17","slug":"database-transactions","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/database-transactions\/","title":{"rendered":"Database transactions"},"content":{"rendered":"<p>Howdy all.  So I&#8217;ve been fighting this weird 404 issue relating to AMP and another plugin I have (Directories Pro).  Seems everyday both plugins go 404.  I thought it was WP-Rocket at first but now I am not so sure.<\/p>\n<p>Anyway, twice a day AMP and Directories stop serving their pages.  I am going to test turning AMP off for a while and see if the problem stops but in trying to diagnose this issue I run across some very strange SQL query behavior.<\/p>\n<p>I recorded 2 minutes of SQL dump from my server and while I do have a big\/busy site, this seems excessive.  I see this query:<\/p>\n<p> DELETE FROM <code>mml_wp_options<\/code> WHERE <code>option_name<\/code> = &#8216;_transient_ampforwp_get_taxonomies&#8217;<\/p>\n<p>About 100 times a <strong>minute<\/strong>.  Further, the reason I feel these may be related, here are some more logs:<\/p>\n<p>2020-09-24T18:14:26.936228Z     1428351 Query   SELECT option_value FROM mml_wp_options WHERE option_name = &#8216;_transient_ampforwp_get_taxonomies&#8217; LIMIT 1<br \/>\n2020-09-24T18:14:26.936771Z     1428354 Query   SELECT option_value FROM mml_wp_options WHERE option_name = &#8216;_transient_ampforwp_get_taxonomies&#8217; LIMIT 1<br \/>\n2020-09-24T18:14:26.936790Z     1428351 Query   INSERT INTO <code>mml_wp_options<\/code> (<code>option_name<\/code>, <code>option_value<\/code>, <code>autoload<\/code>) VALUES (&#8216;_transient_ampforwp_get_taxonomies&#8217;, &#8216;a:7:{s:16:\\&#8221;event-categories\\&#8221;;s:14:\\&#8221;Event Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_cat\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Category\\&#8221;;s:16:\\&#8221;listings_dir_cat\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_tag\\&#8221;;s:18:\\&#8221;Dining Guide &#8211; Tag\\&#8221;;s:16:\\&#8221;listings_dir_tag\\&#8221;;s:24:\\&#8221;Directory Listings &#8211; Tag\\&#8221;;s:20:\\&#8221;dining_guide_loc_loc\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Location\\&#8221;;s:16:\\&#8221;listings_loc_loc\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Location\\&#8221;;}&#8217;, &#8216;yes&#8217;) ON DUPLICATE KEY UPDATE <code>option_name<\/code> = VALUES(<code>option_name<\/code>), <code>option_value<\/code> = VALUES(<code>option_value<\/code>), <code>autoload<\/code> = VALUES(<code>autoload<\/code>)<br \/>\n2020-09-24T18:14:26.937542Z     1428354 Query   INSERT INTO <code>mml_wp_options<\/code> (<code>option_name<\/code>, <code>option_value<\/code>, <code>autoload<\/code>) VALUES (&#8216;_transient_ampforwp_get_taxonomies&#8217;, &#8216;a:7:{s:16:\\&#8221;event-categories\\&#8221;;s:14:\\&#8221;Event Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_cat\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Category\\&#8221;;s:16:\\&#8221;listings_dir_cat\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_tag\\&#8221;;s:18:\\&#8221;Dining Guide &#8211; Tag\\&#8221;;s:16:\\&#8221;listings_dir_tag\\&#8221;;s:24:\\&#8221;Directory Listings &#8211; Tag\\&#8221;;s:20:\\&#8221;dining_guide_loc_loc\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Location\\&#8221;;s:16:\\&#8221;listings_loc_loc\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Location\\&#8221;;}&#8217;, &#8216;yes&#8217;) ON DUPLICATE KEY UPDATE <code>option_name<\/code> = VALUES(<code>option_name<\/code>), <code>option_value<\/code> = VALUES(<code>option_value<\/code>), <code>autoload<\/code> = VALUES(<code>autoload<\/code>)<br \/>\n2020-09-24T18:14:27.333675Z     1428352 Query   SELECT autoload FROM mml_wp_options WHERE option_name = &#8216;_transient_ampforwp_get_taxonomies&#8217;<br \/>\n2020-09-24T18:14:27.335178Z     1428352 Query   DELETE FROM <code>mml_wp_options<\/code> WHERE <code>option_name<\/code> = &#8216;_transient_ampforwp_get_taxonomies&#8217;<br \/>\n2020-09-24T18:14:27.343437Z     1428352 Query   SELECT option_value FROM mml_wp_options WHERE option_name = &#8216;_transient_ampforwp_get_taxonomies&#8217; LIMIT 1<br \/>\n2020-09-24T18:14:27.344059Z     1428352 Query   INSERT INTO <code>mml_wp_options<\/code> (<code>option_name<\/code>, <code>option_value<\/code>, <code>autoload<\/code>) VALUES (&#8216;_transient_ampforwp_get_taxonomies&#8217;, &#8216;a:7:{s:16:\\&#8221;event-categories\\&#8221;;s:14:\\&#8221;Event Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_cat\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Category\\&#8221;;s:16:\\&#8221;listings_dir_cat\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Category\\&#8221;;s:20:\\&#8221;dining_guide_dir_tag\\&#8221;;s:18:\\&#8221;Dining Guide &#8211; Tag\\&#8221;;s:16:\\&#8221;listings_dir_tag\\&#8221;;s:24:\\&#8221;Directory Listings &#8211; Tag\\&#8221;;s:20:\\&#8221;dining_guide_loc_loc\\&#8221;;s:23:\\&#8221;Dining Guide &#8211; Location\\&#8221;;s:16:\\&#8221;listings_loc_loc\\&#8221;;s:29:\\&#8221;Directory Listings &#8211; Location\\&#8221;;}&#8217;, &#8216;yes&#8217;) ON DUPLICATE KEY UPDATE <code>option_name<\/code> = VALUES(<code>option_name<\/code>), <code>option_value<\/code> = VALUES(<code>option_value<\/code>), <code>autoload<\/code> = VALUES(<code>autoload<\/code>)<\/p>\n<p>The AMP plugin is grabbing those taxonomies from the Directories plugin, and I&#8217;m not sure why.<\/p>\n<p>I cannot find a system cron or a WP cron at the hours of 11:15 am and 11:15 pm (twice daily) but this is when amp and Directories stop working and go 404.  The fix is to run WordPress optimize database and it all comes back.<\/p>\n<p>Any ideas?  Any nudges in the right direction would be helpful, losing sleep over this one.<\/p>\n","protected":false},"template":"","class_list":["post-13451315","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13451315","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\/13451315\/revisions"}],"predecessor-version":[{"id":13451328,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13451315\/revisions\/13451328"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13451315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}