LoadBalancer::getLaggedSlaveMode needs to know about the wiki
authorMarius Hoch <hoo@online.de>
Tue, 13 Oct 2015 20:50:47 +0000 (22:50 +0200)
committerMarius Hoch <hoo@online.de>
Tue, 13 Oct 2015 20:54:42 +0000 (22:54 +0200)
If not asked for the current wiki.

This is relevant in setups with LBFactoryMulti where one LoadBalancer
only knows about some database servers and not necessarily about the
ones of the current wiki, but we still try to open a connection with
the current wiki database.

Change-Id: Ie6a87c587c68df6380e568a16c57f7a05ec084f6

includes/db/loadbalancer/LoadBalancer.php

index fbc8c8c..eda374a 100644 (file)
@@ -549,7 +549,7 @@ class LoadBalancer {
                }
 
                # Make master connections read only if in lagged slave mode
-               if ( $masterOnly && $this->getServerCount() > 1 && $this->getLaggedSlaveMode() ) {
+               if ( $masterOnly && $this->getServerCount() > 1 && $this->getLaggedSlaveMode( $wiki ) ) {
                        $conn->setLBInfo( 'readOnlyReason',
                                'The database has been automatically locked ' .
                                'while the slave database servers catch up to the master'
@@ -1142,11 +1142,13 @@ class LoadBalancer {
 
        /**
         * @note This method will trigger a DB connection if not yet done
+        *
+        * @param string|bool $wiki Wiki ID, or false for the current wiki
         * @return bool Whether the generic connection for reads is highly "lagged"
         */
-       public function getLaggedSlaveMode() {
+       public function getLaggedSlaveMode( $wiki = false ) {
                # Get a generic reader connection
-               $this->getConnection( DB_SLAVE );
+               $this->getConnection( DB_SLAVE, false, $wiki );
 
                return $this->mLaggedSlaveMode;
        }