hook_flush_caches gets unintentionally invoked on system_cron() as well as drupal_flush_all_caches(). As a result, it regenerates breakpoints and kills menu and theme caches for all themes enabled every single time.
This is a major issue for sites that have cron running every minute and even if you use cron managers, this still gets invoked because it's called in system_cron function.
While breakpoint regeneration is needed and should be regenerated on actual cache clean, this also gets invoked on settings form submit and on system_cron.
For breakpoints to be regenerated, this module has implemented hook_flush_caches, but it collides with this part of system_cron function.
$core = array('cache', 'cache_path', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
$cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
foreach ($cache_tables as $table) {
cache_clear_all(NULL, $table);
}
The only way to distinguish where it is invoked, we are must trace code execution and run this code only when it's run trough drupal_flush_all_caches function (this function is called by both UI cache clean and drush cc all, so it's safe). This approach is also used by memcache module for slightly different purpose and is related to issue http://drupal.org/node/81461
Stack trace for breakpoints_flush_caches:
$trace[3] drupal_flush_all_caches
$trace[3] system_cron
This is proposed solution for breakpoints_flush_caches function, will attach patch shortly:
$backtrace = debug_backtrace();
if (isset($backtrace[3]) && ($backtrace[3]['function'] == 'drupal_flush_all_caches') && empty($backtrace[3]['args'])) {
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | breakpoints-flush-caches-2505127-7-D7.patch | 4.73 KB | Yaron Tal |
| #4 | 2505127-breakpoints-flush-caches.patch | 4.53 KB | RavindraSingh |
| #2 | breakpoints_flush_caches_separation-2505127-1.patch | 1.31 KB | Jānis Bebrītis |
Comments
Comment #1
Jānis Bebrītis commentedComment #2
Jānis Bebrītis commentedpatch for proposed solution
Comment #3
Jānis Bebrītis commentedComment #4
RavindraSingh commentedBefore applying the patch, please review https://www.drupal.org/node/2378449
-Performance issue with Breakpoints doubling time for drush cc all
Download https://www.drupal.org/files/issues/2415363-breakpoints-menu_rebuild-13.... patch and apply this.
Comment #5
attiks commented#2378449: Performance issue with Breakpoints doubling time for drush cc all is committed, this patch adds a lot of code style fixes, but needs a reroll
Comment #6
dave reidComment #7
Yaron Tal commentedreroll with these additions:
- Removed $config = breakpoints_settings(); from breakpoints_breakpoint_empty_array() since the output was not used nor was there any static or anything filled.
- Removed "return" from breakpoints_breakpoint_group_delete() and breakpoints_breakpoint_group_delete_by_name() since the function they called (breakpoints_breakpoint_group_delete_by_fullkey()) does not return anything either.
Comment #8
Yaron Tal commentedComment #9
attiks commentedCan somebody review this, so I can commit it?
Comment #10
gugalamaciek commentedI applied patch #7, it works - it is invoked during cache clear, but not in system_cron.
Comment #11
attiks commentedThanks all