Add $maxlag parameter to LoadBalancer::getMaxLag() so it'll actually select the right...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 5 Jan 2010 23:39:16 +0000 (23:39 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 5 Jan 2010 23:39:16 +0000 (23:39 +0000)
includes/GlobalFunctions.php
includes/db/LoadBalancer.php

index 4d1f1f5..9664e32 100644 (file)
@@ -3146,7 +3146,7 @@ function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
 function wfWaitForSlaves( $maxLag, $wiki = false ) {
        if( $maxLag ) {
                $lb = wfGetLB( $wiki );
-               list( $host, $lag ) = $lb->getMaxLag();
+               list( $host, $lag ) = $lb->getMaxLag( $wiki );
                while( $lag > $maxLag ) {
                        $name = @gethostbyaddr( $host );
                        if( $name !== false ) {
index 68d142c..cbf824b 100644 (file)
@@ -878,14 +878,18 @@ class LoadBalancer {
         * Get the hostname and lag time of the most-lagged slave.
         * This is useful for maintenance scripts that need to throttle their updates.
         * May attempt to open connections to slaves on the default DB.
+        * @param $wiki string Wiki ID, or false for the default database
         */
-       function getMaxLag() {
+       function getMaxLag( $wiki = false ) {
                $maxLag = -1;
                $host = '';
                foreach ( $this->mServers as $i => $conn ) {
-                       $conn = $this->getAnyOpenConnection( $i );
+                       $conn = false;
+                       if ( $wiki === false ) {
+                               $conn = $this->getAnyOpenConnection( $i );
+                       }
                        if ( !$conn ) {
-                               $conn = $this->openConnection( $i );
+                               $conn = $this->openConnection( $i, $wiki );
                        }
                        if ( !$conn ) {
                                continue;