Download & Extend

cache_admin_menu table truncated 400+ times when clearing the cache

Project:Administration menu
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Our DBA noticed a huge number of truncates being executed during a full cache clear. To my knowledge, there were only a dozen or so tables that get wiped when one clears the cache.
I put some logging into the database layer in the core (includes/database/query.inc ln 908):

<?php
$options
['return'] = Database::RETURN_AFFECTED;
parent::__construct($connection, $options);
# ouput the table getting truncated
echo $table . "\n";
$this->table = $table;
?>

The test:
user@server:/var/www/drupal# drush cc all 
cache_views
cache_admin_menu
menu_router
cache_admin_menu
cache_admin_menu
cache_admin_menu
...400+ more entries...
cache_admin_menu
cache_admin_menu
cache_admin_menu
cache_menu
cache_admin_menu
cache_block
cache_field
cache_image
cache_token
cache_variable
cache_views
cache_views_data
cache
cache_path
cache_filter
cache_bootstrap
cache_page


The sheer number of truncates here causes huge performance bottlenecks, and occasionally causes apache to spin out of control, run out of memory, and bring the whole server down. What gives? In the mean time, I'll be using the safer, albiet less user-friendly, toolbar.

***UPDATE***

The truncates occur from the following chain of commands (stack trace):
#0 DatabaseConnection->truncate(cache_admin_menu, Array ([target] => default)) called at [/var/www/drupal/includes/database/database.inc:2471]
#1 db_truncate(cache_admin_menu) called at [/var/www/drupal/includes/cache.inc:521]
#2 DrupalDatabaseCache->clear(*, 1) called at [/var/www/drupal/includes/cache.inc:176]
#3 cache_clear_all(*, cache_admin_menu, 1) called at [/var/www/drupal/sites/all/modules/admin_menu/admin_menu.module:736]
#4 admin_menu_flush_caches() called at [/var/www/drupal/sites/all/modules/admin_menu/admin_menu.module:126]
---gets pretty long after this, so the rest are just snippets---
#5 admin_menu_menu_link_update(Array ([title] => Top search phrases,
#6 call_user_func_array(admin_menu_menu_link_update
#7 module_invoke_all(menu_link_update
#8 menu_link_save(Array ([title] => Top search phrases
#9 _menu_navigation_links_rebuild(Array ([rss.xml] => Array ([
#10 menu_rebuild() called at [/var/www/drupal/includes/common.inc:7309]
#11 drupal_flush_all_caches() called at [/root/drush-7.x-5.6/commands/core/cache.drush.inc:241]
#12 drush_cache_clear_both()
...and then some stuff in the drush bootstrap

Comments

#1

Thanks, but to make any sense of this, we need to know where those calls are coming from. (i.e., via debug_backtrace())

#2

Status:active» needs review

Can you test this patch? Works for me.

AttachmentSizeStatusTest resultOperations
admin_menu.cache-flush.2.patch1.19 KBIdlePASSED: [[SimpleTest]]: [MySQL] 228 pass(es).View details

#3

Status:needs review» fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

#4

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here