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):
$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
Comment | File | Size | Author |
---|---|---|---|
#2 | admin_menu.cache-flush.2.patch | 1.19 KB | sun |
Comments
Comment #0.0
mcm.guaba CreditAttribution: mcm.guaba commentedspace
Comment #1
sunThanks, but to make any sense of this, we need to know where those calls are coming from. (i.e., via
debug_backtrace()
)Comment #1.0
sunshear to sheer
Comment #1.1
mcm.guaba CreditAttribution: mcm.guaba commentedstacktrace
Comment #1.2
mcm.guaba CreditAttribution: mcm.guaba commenteddedupe update
Comment #1.3
mcm.guaba CreditAttribution: mcm.guaba commentedformatting
Comment #2
sunCan you test this patch? Works for me.
Comment #3
sunThanks 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.
Comment #4.0
(not verified) CreditAttribution: commentedchange to chain