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';
$this->mForce = -1;
$this->mLastIndex = -1;
$this->mErrorConnection = false;
+ $this->mAllowLag = false;
}
function newFromParams( $servers, $failFunction = false, $waitTimeout = 10 )
$done = false;
$totalElapsed = 0;
do {
- if ( $wgReadOnly ) {
+ if ( $wgReadOnly or $this->mAllowLagged ) {
$i = $this->pickRandom( $loads );
} else {
$i = $this->getRandomNonLagged( $loads );
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 ) {