ParserCache: Delete old-style key when saving
authorBrad Jorsch <bjorsch@wikimedia.org>
Sun, 11 Jun 2017 15:21:21 +0000 (11:21 -0400)
committerAnomie <bjorsch@wikimedia.org>
Wed, 14 Jun 2017 13:42:36 +0000 (13:42 +0000)
It was noticed that disk usage on the parser cache machines was
increasing since shortly after wmf.4 was redeployed everywhere on the
9th. One theory is that I7fb9ffca9 causes this by making reparses for an
existing old-style cache entry start writing the new-style key where
they would previously have overwritten the old-style key. On that
theory, let's delete that old-style key (that should now be useless) on
save.

I'm assuming here that firing a blind delete for keys that probably
don't exist in the cache (i.e. every new edit) isn't going to hurt
anything. If that's not the case, we'd need to check existence before
deleting.

Bug: T167784
Change-Id: Ie5efb05722cb7da2a90da195a1f244468177175d

includes/parser/ParserCache.php

index 9c6cf93..1f0e19e 100644 (file)
@@ -327,6 +327,13 @@ class ParserCache {
                        // ...and its pointer
                        $this->mMemc->set( $this->getOptionsKey( $page ), $optionsKey, $expire );
 
+                       // Normally, when there was no key change, the above would have
+                       // overwritten the old entry. Delete that old entry to save disk
+                       // space.
+                       $oldParserOutputKey = $this->getParserOutputKey( $page,
+                               $popts->optionsHashPre30( $optionsKey->mUsedOptions, $page->getTitle() ) );
+                       $this->mMemc->delete( $oldParserOutputKey );
+
                        Hooks::run(
                                'ParserCacheSaveComplete',
                                [ $this, $parserOutput, $page->getTitle(), $popts, $revId ]