Merge "Lower CDN cache TTL when slave lag is high"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Oct 2015 02:01:34 +0000 (02:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Oct 2015 02:01:34 +0000 (02:01 +0000)
1  2 
includes/db/loadbalancer/LoadBalancer.php

@@@ -546,14 -546,6 +546,14 @@@ class LoadBalancer 
                        $trxProf->recordConnection( $host, $dbname, $masterOnly );
                }
  
 +              # Make master connections read only if in lagged slave mode
 +              if ( $masterOnly && $this->getServerCount() > 1 && $this->getLaggedSlaveMode() ) {
 +                      $conn->setLBInfo( 'readOnlyReason',
 +                              'The database has been automatically locked ' .
 +                              'while the slave database servers catch up to the master'
 +                      );
 +              }
 +
                return $conn;
        }
  
        }
  
        /**
+        * @note This method will trigger a DB connection if not yet done
         * @return bool Whether the generic connection for reads is highly "lagged"
         */
        public function getLaggedSlaveMode() {
                return $this->mLaggedSlaveMode;
        }
  
+       /**
+        * @note This method will never cause a new DB connection
+        * @return bool Whether any generic connection used for reads was highly "lagged"
+        * @since 1.27
+        */
+       public function laggedSlaveUsed() {
+               return $this->mLaggedSlaveMode;
+       }
        /**
         * Disables/enables lag checks
         * @param null|bool $mode