From cbc8451d71d33ed290c808047ba237ab906d6494 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 7 Aug 2019 05:37:11 -0700 Subject: [PATCH] rdbms: remove IDatabase::clearFlag() calls made redundant by QUERY_IGNORE_DBO_TRX Change-Id: I493c63f94c813ad71dc2eb8eaf9119a1f11d62cb --- includes/libs/rdbms/database/Database.php | 6 ++--- .../libs/rdbms/database/DatabaseMysqlBase.php | 26 +++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 6029f779e7..0e08044357 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -4279,10 +4279,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware } // This will reconnect if possible or return false if not - $this->clearFlag( self::DBO_TRX, self::REMEMBER_PRIOR ); - $ok = ( $this->query( self::$PING_QUERY, __METHOD__, true ) !== false ); - $this->restoreFlags( self::RESTORE_PRIOR ); - + $flags = self::QUERY_IGNORE_DBO_TRX | self::QUERY_SILENCE_ERRORS; + $ok = ( $this->query( self::$PING_QUERY, __METHOD__, $flags ) !== false ); if ( $ok ) { $rtt = $this->lastRoundTripEstimate; } diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index a9223ac3b9..ac8c7c3105 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -814,22 +814,16 @@ abstract class DatabaseMysqlBase extends Database { protected function getHeartbeatData( array $conds ) { // Query time and trip time are not counted $nowUnix = microtime( true ); - // Do not bother starting implicit transactions here - $this->clearFlag( self::DBO_TRX, self::REMEMBER_PRIOR ); - try { - $whereSQL = $this->makeList( $conds, self::LIST_AND ); - // Use ORDER BY for channel based queries since that field might not be UNIQUE. - // 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", - __METHOD__, - self::QUERY_SILENCE_ERRORS | self::QUERY_IGNORE_DBO_TRX - ); - $row = $res ? $res->fetchObject() : false; - } finally { - $this->restoreFlags(); - } + $whereSQL = $this->makeList( $conds, self::LIST_AND ); + // Use ORDER BY for channel based queries since that field might not be UNIQUE. + // 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", + __METHOD__, + self::QUERY_SILENCE_ERRORS | self::QUERY_IGNORE_DBO_TRX + ); + $row = $res ? $res->fetchObject() : false; return [ $row ? $row->ts : null, $nowUnix ]; } -- 2.20.1