Performance fix for ‘photocrati_cache_tracker’ transient cache
-
Related: https://www.ads-software.com/support/topic/what-does-photocrati_cache_tracker-do/
On our large WP Multisite installation where a number of sites are running nextgen-gallery, we ran into problems where MySQL was taking up enormous amounts of disk space. We determined that part of the problem is the ‘photocrati_cache_tracker’ “transient manager” system in nextgen-gallery. Specifically, on each site where this option was present, the array in the ‘photocrati_cache_tracker’ option was being filled with many thousands of duplicate entries, which was causing the options tables to get large, thereby causing problems with binary logs as well as the way that the IDB storage engine allocates free space. So, for example, we’d have an option with values like:
142978 => '2951165530', 142979 => '2951165530', 142980 => '2951165530', 142981 => '2951165530', 142982 => '2951165530', 142983 => '2951165530', 142984 => '2951165530', 142985 => '2951165530', 142986 => '2951165530', 142987 => '2951165530', 142988 => '2951165530', // many thousands of times
In my investigations of the root cause, I hypothesized that there should *not* be duplicate entries. Looking at the codebase, it seemed that there should be a duplicate check in the
_track_key()
method: https://plugins.trac.www.ads-software.com/browser/nextgen-gallery/tags/3.35/non_pope/class.photocrati_transient_manager.php#L118As such, I made the following change on our installation several weeks ago:
diff --git a/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php b/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php index 41d0f49f46..70fae00b2e 100644 --- a/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php +++ b/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php @@ -127,7 +127,10 @@ class C_Photocrati_Transient_Manager $id = $parts[1]; if (!isset($this->_tracker[$group])) $this->_tracker[$group] = array(); - $this->_tracker[$group][] = $id; + + if ( ! in_array( $id, $this->_tracker[ $group ] ) ) { + $this->_tracker[$group][] = $id; + } } }
After clearing out existing caches and running this modification for a few weeks, the problem seems to have gone away: the ‘photocrati_cache_tracker’ option is being populated without duplicates, and we haven’t noticed any negative side-effects.
We hope your team will consider reviewing this change to see whether they can imagine any bad effects from the proposed change.
- The topic ‘Performance fix for ‘photocrati_cache_tracker’ transient cache’ is closed to new replies.