$this->mMemc->set( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
$this->loadFromDB();
# Save in memcached
- if ( !$this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry ) ) {
- # Hack for slabs reassignment problem
- $this->mMemc->set( $this->mMemcKey, "error" );
+ # Keep trying if it fails, this is kind of important
+ for ( $i=0; $i<20 && !$this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry ); $i++ ) {
+ usleep(mt_rand(500000,1500000));
+ }
+ if ( $i == 20 ) {
+ $this->mMemc->set( $this->mMemcKey, "error", 86400 );
wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
}
$this->unlock();
if ( !is_array( $this->mCache ) ) {
# If it is 'loading' or 'error', switch to individual message mode, otherwise disable
+ # Causing too much DB load, disabling -- TS
+ $this->mDisable = true;
+ /*
if ( $this->mCache == "loading" ) {
$this->mUseCache = false;
} elseif ( $this->mCache == "error" ) {
} else {
$this->mDisable = true;
$success = false;
- }
+ }*/
$this->mCache = false;
}
}
# Loads all cacheable messages from the database
function loadFromDB()
{
- $fname = "MessageCache::loadFromDB";
+ global $wgLoadBalancer;
+ $fname = "MessageCache::loadFromDB";
+ $wgLoadBalancer->force(-1);
$sql = "SELECT cur_title,cur_text FROM cur WHERE cur_is_redirect=0 AND cur_namespace=" . NS_MEDIAWIKI;
$res = wfQuery( $sql, DB_READ, $fname );
-
+ $wgLoadBalancer->force(0);
$this->mCache = array();
for ( $row = wfFetchObject( $res ); $row; $row = wfFetchObject( $res ) ) {
$this->mCache[$row->cur_title] = $row->cur_text;