From: Aaron Schulz Date: Thu, 29 Mar 2018 23:14:37 +0000 (-0700) Subject: rdbms: update IDatabase::getLag comments X-Git-Tag: 1.31.0-rc.0~237^2~1 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4255b4fa6dd303f2c2db65ff67f02c2c561e4821 rdbms: update IDatabase::getLag comments Also add missing __METHOD__ to getLagFromPtHeartbeat() Change-Id: I4257b1d47a88779b47d807a881561c331ff3aa30 --- diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 286d65881e..315c9eb0ec 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -749,6 +749,7 @@ abstract class DatabaseMysqlBase extends Database { protected function getLagFromSlaveStatus() { $res = $this->query( 'SHOW SLAVE STATUS', __METHOD__ ); $row = $res ? $res->fetchObject() : false; + // If the server is not replicating, there will be no row if ( $row && strval( $row->Seconds_Behind_Master ) !== '' ) { return intval( $row->Seconds_Behind_Master ); } @@ -856,7 +857,8 @@ abstract class DatabaseMysqlBase extends Database { // Note: this would use "TIMESTAMPDIFF(MICROSECOND,ts,UTC_TIMESTAMP(6))" but the // percision field is not supported in MySQL <= 5.5. $res = $this->query( - "SELECT ts FROM heartbeat.heartbeat WHERE $whereSQL ORDER BY ts DESC LIMIT 1" + "SELECT ts FROM heartbeat.heartbeat WHERE $whereSQL ORDER BY ts DESC LIMIT 1", + __METHOD__ ); $row = $res ? $res->fetchObject() : false; } finally { diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index 07f1e2336f..545c8e36f7 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -1752,11 +1752,9 @@ interface IDatabase { public function ping( &$rtt = null ); /** - * Get replica DB lag. Currently supported only by MySQL. + * Get the amount of replication lag for this database server * - * Note that this function will generate a fatal error on many - * installations. Most callers should use LoadBalancer::safeGetLag() - * instead. + * Callers should avoid using this method while a transaction is active * * @return int|bool Database replication lag in seconds or false on error * @throws DBError