From: Tim Starling Date: Mon, 24 Oct 2005 20:38:46 +0000 (+0000) Subject: Meaningful error message when all servers are busy X-Git-Tag: 1.6.0~1333 X-Git-Url: http://git.cyclocoop.org/geomaker.php?a=commitdiff_plain;h=396a10950459f8cdde588e14d628de33b63b48fa;p=lhc%2Fweb%2Fwiklou.git Meaningful error message when all servers are busy --- diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index 326a83fbcf..89860d792f 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -36,7 +36,7 @@ class LoadBalancer { /* private */ var $mFailFunction, $mErrorConnection; /* private */ var $mForce, $mReadIndex, $mLastIndex; /* private */ var $mWaitForFile, $mWaitForPos, $mWaitTimeout; - /* private */ var $mLaggedSlaveMode; + /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; function LoadBalancer() { @@ -225,6 +225,10 @@ class LoadBalancer { } } while ( count( $loads ) && !$done && $totalElapsed / 1e6 < $wgDBClusterTimeout ); + if ( $totalElapsed / 1e6 >= $wgDBClusterTimeout ) { + $this->mLastError = 'All servers busy'; + } + if ( $i !== false && $this->isOpen( $i ) ) { # Wait for the session master pos for a short time if ( $this->mWaitForFile ) { @@ -446,14 +450,23 @@ class LoadBalancer { if ( !$reporting ) { $reporting = true; if ( !is_object( $conn ) ) { + // No last connection, probably due to all servers being too busy $conn = new Database; - } - if ( $this->mFailFunction ) { - $conn->failFunction( $this->mFailFunction ); + if ( $this->mFailFunction ) { + $conn->failFunction( $this->mFailFunction ); + $conn->reportConnectionError(); + } else { + // If all servers were busy, mLastError will contain something sensible + wfEmergencyAbort( $conn, $this->mLastError ); + } } else { - $conn->failFunction( false ); + if ( $this->mFailFunction ) { + $conn->failFunction( $this->mFailFunction ); + } else { + $conn->failFunction( false ); + } + $conn->reportConnectionError(); } - $conn->reportConnectionError(); $reporting = false; } wfProfileOut( $fname );