From: Domas Mituzas Date: Mon, 23 Jan 2006 15:27:44 +0000 (+0000) Subject: allow bypassing lag checks X-Git-Tag: 1.6.0~441 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=3488efe876c45b1048fb38d8fb93710fbf301628;p=lhc%2Fweb%2Fwiklou.git allow bypassing lag checks --- diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index c3f87d42ca..eb1aa59c8c 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -34,7 +34,7 @@ define( 'AVG_STATUS_POLL', 2000 ); class LoadBalancer { /* private */ var $mServers, $mConnections, $mLoads, $mGroupLoads; /* private */ var $mFailFunction, $mErrorConnection; - /* private */ var $mForce, $mReadIndex, $mLastIndex; + /* private */ var $mForce, $mReadIndex, $mLastIndex, $mAllowLagged; /* private */ var $mWaitForFile, $mWaitForPos, $mWaitTimeout; /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; @@ -47,6 +47,7 @@ class LoadBalancer { $this->mForce = -1; $this->mLastIndex = -1; $this->mErrorConnection = false; + $this->mAllowLag = false; } function newFromParams( $servers, $failFunction = false, $waitTimeout = 10 ) @@ -178,7 +179,7 @@ class LoadBalancer { $done = false; $totalElapsed = 0; do { - if ( $wgReadOnly ) { + if ( $wgReadOnly or $this->mAllowLagged ) { $i = $this->pickRandom( $loads ); } else { $i = $this->getRandomNonLagged( $loads ); @@ -558,6 +559,13 @@ class LoadBalancer { return $this->mLaggedSlaveMode; } + /* Disables/enables lag checks */ + function allowLagged($mode=null) { + if ($mode===null) + return $this->mAllowLagged; + $this->mAllowLagged=$mode; + } + function pingAll() { $success = true; foreach ( $this->mConnections as $i => $conn ) {