jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/328859 )

Change subject: Avoid starting transactions in getHeartbeatData()
......................................................................


Avoid starting transactions in getHeartbeatData()

This can avoid excess round trips in LoadBalancer::getLagTimes()

Change-Id: Ibe9558cc825c5a0dd03ea109926ff15d00c60e31
---
M includes/libs/rdbms/database/DatabaseMysqlBase.php
1 file changed, 14 insertions(+), 8 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php 
b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index 668443b..5d680e2 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -756,14 +756,20 @@
         * @see 
https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html
         */
        protected function getHeartbeatData( array $conds ) {
-               $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"
-               );
-               $row = $res ? $res->fetchObject() : false;
+               // 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"
+                       );
+                       $row = $res ? $res->fetchObject() : false;
+               } finally {
+                       $this->restoreFlags();
+               }
 
                return [ $row ? $row->ts : null, microtime( true ) ];
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/328859
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibe9558cc825c5a0dd03ea109926ff15d00c60e31
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to