r98200 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98199‎ | r98200 | r98201 >
Date:00:41, 27 September 2011
Author:brion
Status:ok
Tags:
Comment:
Debug logging and possible fix for bug 31177: mystery sidebar message failures

This may be related to things failing on load from External Storage; however we have not yet been able to verify this.

Tweaks MessageCache::loadFromDB() and MessageCache::getMsgFromNamespace() to avoid storing empty cache entries when loading text fails.
When building initial cache if we get a failure we'll log and store a '!TOO BIG' message which requests on-demand load later.
If an on-demand load failures, we'll log and return the false through but won't update the cache with the bad value.

To enable the logging in production, set up a $wgDebugLogFiles entry for 'MessageCache'.

Note that MessageCache::loadFromDB() bypasses Revision's text entry memcaching and may cause a lot of ES fetches at once.
However any ES failures *should* already be logged in the 'ExternalStoreDB' log file.
Modified paths:
  • /trunk/phase3/includes/cache/MessageCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/cache/MessageCache.php
@@ -428,7 +428,16 @@
429429 );
430430
431431 foreach ( $res as $row ) {
432 - $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row );
 432+ $text = Revision::getRevisionText( $row );
 433+ if( $text === false ) {
 434+ // Failed to fetch data; possible ES errors?
 435+ // Store a marker to fetch on-demand as a workaround...
 436+ $entry = '!TOO BIG';
 437+ wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$row->page_title} ($code)" );
 438+ } else {
 439+ $entry = ' ' . $text;
 440+ }
 441+ $cache[$row->page_title] = $entry;
433442 }
434443
435444 foreach ( $mostused as $key ) {
@@ -741,8 +750,13 @@
742751 $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) );
743752 if ( $revision ) {
744753 $message = $revision->getText();
745 - $this->mCache[$code][$title] = ' ' . $message;
746 - $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry );
 754+ if ($message === false) {
 755+ // A possibly temporary loading failure.
 756+ wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title->getDbKey()} ($code)" );
 757+ } else {
 758+ $this->mCache[$code][$title] = ' ' . $message;
 759+ $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry );
 760+ }
747761 } else {
748762 $message = false;
749763 $this->mCache[$code][$title] = '!NONEXISTENT';

Follow-up revisions

RevisionCommit summaryAuthorDate
r98201MFT r98200: logging and possible fix for bug 31177: sidebar message load fail...brion00:42, 27 September 2011
r98203MFT r98200: logging and possible fix for bug 31177: sidebar message load fail...brion00:50, 27 September 2011

Status & tagging log