Renamed some variables from "slave" to "replica"
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 6 Sep 2016 00:09:08 +0000 (17:09 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 6 Sep 2016 06:03:01 +0000 (23:03 -0700)
Change-Id: I455278294cd7ea344d14a76ac5957ece2e07fbf3

includes/WatchedItemStore.php
includes/api/ApiMain.php
includes/jobqueue/JobRunner.php
includes/objectcache/SqlBagOStuff.php
includes/user/User.php

index 6986a2f..9a74401 100644 (file)
@@ -190,13 +190,13 @@ class WatchedItemStore implements StatsdAwareInterface {
        }
 
        /**
-        * @param int $slaveOrMaster DB_MASTER or DB_REPLICA
+        * @param int $dbIndex DB_MASTER or DB_REPLICA
         *
         * @return DatabaseBase
         * @throws MWException
         */
-       private function getConnection( $slaveOrMaster ) {
-               return $this->loadBalancer->getConnection( $slaveOrMaster, [ 'watchlist' ] );
+       private function getConnection( $dbIndex ) {
+               return $this->loadBalancer->getConnection( $dbIndex, [ 'watchlist' ] );
        }
 
        /**
index 2ce5120..1f3c76a 100644 (file)
@@ -1323,8 +1323,8 @@ class ApiMain extends ApiBase {
                }
 
                // If a majority of replica DBs are too lagged then disallow writes
-               $slaveCount = wfGetLB()->getServerCount() - 1;
-               if ( $numLagged >= ceil( $slaveCount / 2 ) ) {
+               $replicaCount = wfGetLB()->getServerCount() - 1;
+               if ( $numLagged >= ceil( $replicaCount / 2 ) ) {
                        $laggedServers = implode( ', ', $laggedServers );
                        wfDebugLog(
                                'api-readonly',
index 134ba9d..f0d5ece 100644 (file)
@@ -118,7 +118,7 @@ class JobRunner implements LoggerAwareInterface {
                // This check should not block as we want to try other wiki queues.
                list( , $maxLag ) = wfGetLB( wfWikiID() )->getMaxLag();
                if ( $maxLag >= self::MAX_ALLOWED_LAG ) {
-                       $response['reached'] = 'slave-lag-limit';
+                       $response['reached'] = 'replica-lag-limit';
                        return $response;
                }
 
@@ -221,7 +221,7 @@ class JobRunner implements LoggerAwareInterface {
                                                        'timeout' => self::MAX_ALLOWED_LAG
                                                ] );
                                        } catch ( DBReplicationWaitError $e ) {
-                                               $response['reached'] = 'slave-lag-limit';
+                                               $response['reached'] = 'replica-lag-limit';
                                                break;
                                        }
                                        $lastCheckTime = microtime( true );
index 4870d5e..3baae50 100644 (file)
@@ -44,7 +44,7 @@ class SqlBagOStuff extends BagOStuff {
        /** @var string */
        protected $tableName = 'objectcache';
        /** @var bool */
-       protected $slaveOnly = false;
+       protected $replicaOnly = false;
        /** @var int */
        protected $syncTimeout = 3;
 
@@ -132,7 +132,7 @@ class SqlBagOStuff extends BagOStuff {
                if ( isset( $params['syncTimeout'] ) ) {
                        $this->syncTimeout = $params['syncTimeout'];
                }
-               $this->slaveOnly = !empty( $params['slaveOnly'] );
+               $this->replicaOnly = !empty( $params['slaveOnly'] );
        }
 
        protected function getSeparateMainLB() {
@@ -183,7 +183,7 @@ class SqlBagOStuff extends BagOStuff {
                                $db = DatabaseBase::factory( $type, $info );
                                $db->clearFlag( DBO_TRX );
                        } else {
-                               $index = $this->slaveOnly ? DB_REPLICA : DB_MASTER;
+                               $index = $this->replicaOnly ? DB_REPLICA : DB_MASTER;
                                if ( $this->getSeparateMainLB() ) {
                                        $db = $this->getSeparateMainLB()->getConnection( $index );
                                        $db->clearFlag( DBO_TRX ); // auto-commit mode
@@ -539,7 +539,7 @@ class SqlBagOStuff extends BagOStuff {
        }
 
        protected function garbageCollect() {
-               if ( !$this->purgePeriod || $this->slaveOnly ) {
+               if ( !$this->purgePeriod || $this->replicaOnly ) {
                        // Disabled
                        return;
                }
index 971ef70..248ea8e 100644 (file)
@@ -3841,7 +3841,7 @@ class User implements IDBAccessObject {
                        // Maybe the problem was a missed cache update; clear it to be safe
                        $this->clearSharedCache( 'refresh' );
                        // User was changed in the meantime or loaded with stale data
-                       $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'slave';
+                       $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'replica';
                        throw new MWException(
                                "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
                                " the version of the user to be saved is older than the current version."