r41928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41927‎ | r41928 | r41929 >
Date:13:02, 10 October 2008
Author:tstarling
Status:old
Tags:
Comment:
Fixed regression from r35821: the status key is meant to prevent DB overload, not memcached overload.
Modified paths:
  • /trunk/phase3/includes/MessageCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MessageCache.php
@@ -260,12 +260,23 @@
261261
262262 $this->lock($cacheKey);
263263
264 - $cache = $this->loadFromDB( $code );
265 - $success = $this->setCache( $cache, $code );
 264+ # Limit the concurrency of loadFromDB to a single process
 265+ # This prevents the site from going down when the cache expires
 266+ $statusKey = wfMemcKey( 'messages', $code, 'status' );
 267+ $success = $this->mMemc->add( $statusKey, 'loading', MSG_LOAD_TIMEOUT );
266268 if ( $success ) {
267 - $this->saveToCaches( $cache, true, $code );
 269+ $cache = $this->loadFromDB( $code );
 270+ $success = $this->setCache( $cache, $code );
268271 }
269 -
 272+ if ( $success ) {
 273+ $success = $this->saveToCaches( $cache, true, $code );
 274+ if ( $success ) {
 275+ $this->mMemc->delete( $statusKey );
 276+ } else {
 277+ $this->mMemc->set( $statusKey, 'error', 60*5 );
 278+ wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
 279+ }
 280+ }
270281 $this->unlock($cacheKey);
271282 }
272283
@@ -413,11 +424,7 @@
414425 global $wgLocalMessageCache, $wgLocalMessageCacheSerialized;
415426
416427 $cacheKey = wfMemcKey( 'messages', $code );
417 - $statusKey = wfMemcKey( 'messages', $code, 'status' );
418428
419 - $success = $this->mMemc->add( $statusKey, 'loading', MSG_LOAD_TIMEOUT );
420 - if ( !$success ) return true; # Other process should be updating them now
421 -
422429 $i = 0;
423430 if ( $memc ) {
424431 # Save in memcached
@@ -443,11 +450,8 @@
444451 }
445452
446453 if ( $i == 20 ) {
447 - $this->mMemc->set( $statusKey, 'error', 60*5 );
448 - wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
449454 $success = false;
450455 } else {
451 - $this->mMemc->delete( $statusKey );
452456 $success = true;
453457 }
454458 wfProfileOut( __METHOD__ );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r35821* Second try of split message caches with changes suggested by Tim Starling a...nikerabbit20:41, 3 June 2008

Status & tagging log