Make mysql getHeartbeatData() method not count query/RTT in estimate
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Aug 2017 19:31:23 +0000 (12:31 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Aug 2017 19:31:23 +0000 (12:31 -0700)
Optimize for the common case where lag does not strictly increase
during trip times instead of being pessimistic.

Change-Id: Ibb0e3faad23862d397e1cc2a9f7e2a8293fa5f2b

includes/libs/rdbms/database/DatabaseMysqlBase.php

index 991e0c6..692ddb7 100644 (file)
@@ -778,6 +778,8 @@ abstract class DatabaseMysqlBase extends Database {
         * @see https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html
         */
        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 {
@@ -793,7 +795,7 @@ abstract class DatabaseMysqlBase extends Database {
                        $this->restoreFlags();
                }
 
-               return [ $row ? $row->ts : null, microtime( true ) ];
+               return [ $row ? $row->ts : null, $nowUnix ];
        }
 
        protected function getApproximateLagStatus() {