From 3488efe876c45b1048fb38d8fb93710fbf301628 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Mon, 23 Jan 2006 15:27:44 +0000 Subject: [PATCH] allow bypassing lag checks --- includes/LoadBalancer.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 ) { -- 2.20.1