Merge "Rename some DB/LB variables to be more consistent"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 5 Sep 2016 08:24:20 +0000 (08:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 5 Sep 2016 08:24:20 +0000 (08:24 +0000)
1  2 
includes/db/Database.php

diff --combined includes/db/Database.php
@@@ -128,7 -128,7 +128,7 @@@ abstract class DatabaseBase implements 
         */
        private $mTrxTimestamp = null;
        /** @var float Lag estimate at the time of BEGIN */
-       private $mTrxSlaveLag = null;
+       private $mTrxReplicaLag = null;
        /**
         * Remembers the function name given for starting the most recent transaction via begin().
         * Used to provide additional context for error reporting.
         * @param float $runtime Total runtime, including RTT
         */
        private function updateTrxWriteQueryTime( $sql, $runtime ) {
-               $indicativeOfSlaveRuntime = true;
+               // Whether this is indicative of replica DB runtime (except for RBR or ws_repl)
+               $indicativeOfReplicaRuntime = true;
                if ( $runtime > self::SLOW_WRITE_SEC ) {
                        $verb = $this->getQueryVerb( $sql );
                        // insert(), upsert(), replace() are fast unless bulky in size or blocked on locks
                        if ( $verb === 'INSERT' ) {
-                               $indicativeOfSlaveRuntime = $this->affectedRows() > self::SMALL_WRITE_ROWS;
+                               $indicativeOfReplicaRuntime = $this->affectedRows() > self::SMALL_WRITE_ROWS;
                        } elseif ( $verb === 'REPLACE' ) {
-                               $indicativeOfSlaveRuntime = $this->affectedRows() > self::SMALL_WRITE_ROWS / 2;
+                               $indicativeOfReplicaRuntime = $this->affectedRows() > self::SMALL_WRITE_ROWS / 2;
                        }
                }
  
                $this->mTrxWriteDuration += $runtime;
                $this->mTrxWriteQueryCount += 1;
-               if ( $indicativeOfSlaveRuntime ) {
+               if ( $indicativeOfReplicaRuntime ) {
                        $this->mTrxWriteAdjDuration += $runtime;
                        $this->mTrxWriteAdjQueryCount += 1;
                }
                return '(' . $this->selectSQLText( $table, $fld, $conds, null, [], $join_conds ) . ')';
        }
  
 +      /**
 +       * @param string $field Field or column to cast
 +       * @return string
 +       * @since 1.28
 +       */
 +      public function buildStringCast( $field ) {
 +              return $field;
 +      }
 +
        public function selectDB( $db ) {
                # Stub. Shouldn't cause serious problems if it's not overridden, but
                # if your database engine supports a concept similar to MySQL's
                // Get an estimate of the replica DB lag before then, treating estimate staleness
                // as lag itself just to be safe
                $status = $this->getApproximateLagStatus();
-               $this->mTrxSlaveLag = $status['lag'] + ( microtime( true ) - $status['since'] );
+               $this->mTrxReplicaLag = $status['lag'] + ( microtime( true ) - $status['since'] );
        }
  
        /**
         */
        public function getTransactionLagStatus() {
                return $this->mTrxLevel
-                       ? [ 'lag' => $this->mTrxSlaveLag, 'since' => $this->trxTimestamp() ]
+                       ? [ 'lag' => $this->mTrxReplicaLag, 'since' => $this->trxTimestamp() ]
                        : null;
        }