From: jenkins-bot Date: Sat, 31 Mar 2018 00:52:09 +0000 (+0000) Subject: Merge "rdbms: update IDatabase::getLag comments" X-Git-Tag: 1.31.0-rc.0~239 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=b163a90a466e657b0f53da4f080422ca785640c5;hp=f1b426c59d1f25a5afc799d0791436dbd6ce6bd3;p=lhc%2Fweb%2Fwiklou.git Merge "rdbms: update IDatabase::getLag comments" --- diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 5e06f28d64..b0fcade719 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