X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=11388e8607f9bbd9ce6905dbe5dfebfd2d60a56f;hb=dadaf48a39454d7d9e5a418da2c7ecb330a3fa35;hp=4eea6624206a9a811ede712bcb3ff2d7047e90d1;hpb=baa62ab1191e5c20637c8ae57e04d6e24305d7c3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4eea662420..11388e8607 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3807,8 +3807,11 @@ function wfWaitForSlaves( $lbs[] = wfGetLB( $wiki ); } - $ok = true; - foreach ( $lbs as $lb ) { + // Get all the master positions of applicable DBs right now. + // This can be faster since waiting on one cluster reduces the + // time needed to wait on the next clusters. + $masterPositions = array_fill( 0, count( $lbs ), false ); + foreach ( $lbs as $i => $lb ) { // bug 27975 - Don't try to wait for slaves if there are none // Prevents permission error when getting master position if ( $lb->getServerCount() > 1 ) { @@ -3819,12 +3822,16 @@ function wfWaitForSlaves( if ( $ifWritesSince && $dbw->lastDoneWrites() < $ifWritesSince ) { continue; // no writes since the last wait } - $pos = $dbw->getMasterPos(); + $masterPositions[$i] = $dbw->getMasterPos(); + } + } + + $ok = true; + foreach ( $lbs as $i => $lb ) { + if ( $masterPositions[$i] ) { // The DBMS may not support getMasterPos() or the whole // load balancer might be fake (e.g. $wgAllDBsAreLocalhost). - if ( $pos !== false ) { - $ok = $lb->waitForAll( $pos, $timeout ) && $ok; - } + $ok = $lb->waitForAll( $masterPositions[$i], $timeout ) && $ok; } }