X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseMysqlBase.php;h=8fca440f67979370b8c8c0f9f68de0d784aad8af;hb=b7d1782e1055cd04338293d1c5ce0f09ffadbff4;hp=58bc5ac8e363b7e3a8b18d538d7befca32f648af;hpb=8515ed36f68d00644d7d15ee0e4f04a49c9b0b91;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 58bc5ac8e3..8fca440f67 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -766,18 +766,20 @@ abstract class DatabaseMysqlBase extends Database { protected function getLagFromPtHeartbeat() { $options = $this->lagDetectionOptions; - $staleness = $this->trxLevel - ? microtime( true ) - $this->trxTimestamp() - : 0; - if ( $staleness > self::LAG_STALE_WARN_THRESHOLD ) { - // Avoid returning higher and higher lag value due to snapshot age - // given that the isolation level will typically be REPEATABLE-READ - $this->queryLogger->warning( - "Using cached lag value for {db_server} due to active transaction", - $this->getLogContext( [ 'method' => __METHOD__ ] ) - ); + $currentTrxInfo = $this->getRecordedTransactionLagStatus(); + if ( $currentTrxInfo ) { + // There is an active transaction and the initial lag was already queried + $staleness = microtime( true ) - $currentTrxInfo['since']; + if ( $staleness > self::LAG_STALE_WARN_THRESHOLD ) { + // Avoid returning higher and higher lag value due to snapshot age + // given that the isolation level will typically be REPEATABLE-READ + $this->queryLogger->warning( + "Using cached lag value for {db_server} due to active transaction", + $this->getLogContext( [ 'method' => __METHOD__, 'age' => $staleness ] ) + ); + } - return $this->getTransactionLagStatus()['lag']; + return $currentTrxInfo['lag']; } if ( isset( $options['conds'] ) ) {