From: Aaron Schulz Date: Fri, 12 Jan 2018 23:18:14 +0000 (-0800) Subject: Fix LoadBalancer::getMasterPos() callers to handle a non-object being returned X-Git-Tag: 1.31.0-rc.0~911^2 X-Git-Url: https://git.heureux-cyclage.org/w/index.php?a=commitdiff_plain;h=8f4ae0d51c8b4c4f77753e157312a91176f5a719;p=lhc%2Fweb%2Fwiklou.git Fix LoadBalancer::getMasterPos() callers to handle a non-object being returned Change-Id: I3356057f27a051835734329afa339ea76842a389 --- diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 152ff74d57..4fcd88599c 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -147,8 +147,10 @@ class ChronologyProtector implements LoggerAwareInterface { $masterName = $lb->getServerName( $lb->getWriterIndex() ); if ( $lb->getServerCount() > 1 ) { $pos = $lb->getMasterPos(); - $this->logger->info( __METHOD__ . ": LB for '$masterName' has pos $pos\n" ); - $this->shutdownPositions[$masterName] = $pos; + if ( $pos ) { + $this->logger->info( __METHOD__ . ": LB for '$masterName' has pos $pos\n" ); + $this->shutdownPositions[$masterName] = $pos; + } } else { $this->logger->info( __METHOD__ . ": DB '$masterName' touched\n" ); } diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 187527e557..2324553016 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -358,7 +358,7 @@ abstract class LBFactory implements ILBFactory { $failed = []; foreach ( $lbs as $i => $lb ) { if ( $masterPositions[$i] ) { - // The DBMS may not support getMasterPos() + // The RDBMS may not support getMasterPos() if ( !$lb->waitForAll( $masterPositions[$i], $opts['timeout'] ) ) { $failed[] = $lb->getServerName( $lb->getWriterIndex() ); } diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index c2860552c0..6691f73d2e 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -808,6 +808,9 @@ class SqlBagOStuff extends BagOStuff { // Main LB is used; wait for any replica DBs to catch up $masterPos = $lb->getMasterPos(); + if ( !$masterPos ) { + return true; // not applicable + } $loop = new WaitConditionLoop( function () use ( $lb, $masterPos ) {