From c3740286ac16935664024f92793a9d7b3677072a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 29 Sep 2015 00:44:48 -0700 Subject: [PATCH] Removed old fake slave hacks used for debug log testing * Any modern automatic tests would use mocking methods Change-Id: I5fbd8ebe7090f75bdcccc7a2848ae88f34a64512 --- includes/db/Database.php | 18 ------- includes/db/DatabaseMysqlBase.php | 59 ----------------------- includes/db/loadbalancer/LoadBalancer.php | 6 --- 3 files changed, 83 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index d442e4b9ed..e4143c63c8 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -322,24 +322,6 @@ abstract class DatabaseBase implements IDatabase { } } - /** - * Set lag time in seconds for a fake slave - * - * @param mixed $lag Valid values for this parameter are determined by the - * subclass, but should be a PHP scalar or array that would be sensible - * as part of $wgLBFactoryConf. - */ - public function setFakeSlaveLag( $lag ) { - } - - /** - * Make this connection a fake master - * - * @param bool $enabled - */ - public function setFakeMaster( $enabled = true ) { - } - /** * @return TransactionProfiler */ diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index 5be96fa452..61a05652d1 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -33,11 +33,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** @var MysqlMasterPos */ protected $lastKnownSlavePos; - /** @var null|int */ - protected $mFakeSlaveLag = null; - - protected $mFakeMaster = false; - /** @var string|null */ private $serverVersion = null; @@ -601,24 +596,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { */ abstract protected function mysqlPing(); - /** - * Set lag time in seconds for a fake slave - * - * @param int $lag - */ - public function setFakeSlaveLag( $lag ) { - $this->mFakeSlaveLag = $lag; - } - - /** - * Make this connection a fake master - * - * @param bool $enabled - */ - public function setFakeMaster( $enabled = true ) { - $this->mFakeMaster = $enabled; - } - /** * Returns slave lag. * @@ -627,12 +604,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * @return int */ function getLag() { - if ( !is_null( $this->mFakeSlaveLag ) ) { - wfDebug( "getLag: fake slave lagged {$this->mFakeSlaveLag} seconds\n" ); - - return $this->mFakeSlaveLag; - } - return $this->getLagFromSlaveStatus(); } @@ -673,25 +644,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { # Commit any open transactions $this->commit( __METHOD__, 'flush' ); - if ( !is_null( $this->mFakeSlaveLag ) ) { - $wait = intval( ( $pos->pos - microtime( true ) + $this->mFakeSlaveLag ) * 1e6 ); - - if ( $wait > $timeout * 1e6 ) { - wfDebug( "Fake slave timed out waiting for $pos ($wait us)\n" ); - - return -1; - } elseif ( $wait > 0 ) { - wfDebug( "Fake slave waiting $wait us\n" ); - usleep( $wait ); - - return 1; - } else { - wfDebug( "Fake slave up to date ($wait us)\n" ); - - return 0; - } - } - # Call doQuery() directly, to avoid opening a transaction if DBO_TRX is set $encFile = $this->addQuotes( $pos->file ); $encPos = intval( $pos->pos ); @@ -715,13 +667,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * @return MySQLMasterPos|bool */ function getSlavePos() { - if ( !is_null( $this->mFakeSlaveLag ) ) { - $pos = new MySQLMasterPos( 'fake', microtime( true ) - $this->mFakeSlaveLag ); - wfDebug( __METHOD__ . ": fake slave pos = $pos\n" ); - - return $pos; - } - $res = $this->query( 'SHOW SLAVE STATUS', 'DatabaseBase::getSlavePos' ); $row = $this->fetchObject( $res ); @@ -742,10 +687,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * @return MySQLMasterPos|bool */ function getMasterPos() { - if ( $this->mFakeMaster ) { - return new MySQLMasterPos( 'fake', microtime( true ) ); - } - $res = $this->query( 'SHOW MASTER STATUS', 'DatabaseBase::getMasterPos' ); $row = $this->fetchObject( $res ); diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index e794fa00ef..6669c679bc 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -803,12 +803,6 @@ class LoadBalancer { } $db->setLBInfo( $server ); - if ( isset( $server['fakeSlaveLag'] ) ) { - $db->setFakeSlaveLag( $server['fakeSlaveLag'] ); - } - if ( isset( $server['fakeMaster'] ) ) { - $db->setFakeMaster( true ); - } return $db; } -- 2.20.1