X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/74c929b24b048c9f1e31e17db757ae4195cd7673..dc9cc5d707f5a612938cc9371614cc41c328fda2:/includes/db/LBFactory.php diff --git a/includes/db/LBFactory.php b/includes/db/LBFactory.php index 256875d7..3876d71f 100644 --- a/includes/db/LBFactory.php +++ b/includes/db/LBFactory.php @@ -236,15 +236,25 @@ class ChronologyProtector { * @param LoadBalancer $lb */ function shutdownLB( $lb ) { - if ( session_id() != '' && $lb->getServerCount() > 1 ) { - $masterName = $lb->getServerName( 0 ); - if ( !isset( $this->shutdownPos[$masterName] ) ) { - $pos = $lb->getMasterPos(); - $info = $lb->parentInfo(); - wfDebug( __METHOD__.": LB " . $info['id'] . " has master pos $pos\n" ); - $this->shutdownPos[$masterName] = $pos; - } + // Don't start a session, don't bother with non-replicated setups + if ( strval( session_id() ) == '' || $lb->getServerCount() <= 1 ) { + return; + } + $masterName = $lb->getServerName( 0 ); + if ( isset( $this->shutdownPos[$masterName] ) ) { + // Already done + return; + } + // Only save the position if writes have been done on the connection + $db = $lb->getAnyOpenConnection( 0 ); + $info = $lb->parentInfo(); + if ( !$db || !$db->doneWrites() ) { + wfDebug( __METHOD__.": LB {$info['id']}, no writes done\n" ); + return; } + $pos = $db->getMasterPos(); + wfDebug( __METHOD__.": LB {$info['id']} has master pos $pos\n" ); + $this->shutdownPos[$masterName] = $pos; } /**