From ea44989fe4d1abf1508f9ebe9264c278ffcc3f35 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 27 Sep 2011 00:41:24 +0000 Subject: [PATCH] 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. --- includes/cache/MessageCache.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 3f787e907f..59ee8c206d 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -428,7 +428,16 @@ class MessageCache { ); foreach ( $res as $row ) { - $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row ); + $text = Revision::getRevisionText( $row ); + if( $text === false ) { + // Failed to fetch data; possible ES errors? + // Store a marker to fetch on-demand as a workaround... + $entry = '!TOO BIG'; + wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$row->page_title} ($code)" ); + } else { + $entry = ' ' . $text; + } + $cache[$row->page_title] = $entry; } foreach ( $mostused as $key ) { @@ -741,8 +750,13 @@ class MessageCache { $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) ); if ( $revision ) { $message = $revision->getText(); - $this->mCache[$code][$title] = ' ' . $message; - $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); + if ($message === false) { + // A possibly temporary loading failure. + wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title->getDbKey()} ($code)" ); + } else { + $this->mCache[$code][$title] = ' ' . $message; + $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); + } } else { $message = false; $this->mCache[$code][$title] = '!NONEXISTENT'; -- 2.20.1