rdbms: mention wait time in LoadBalancer::safeWaitForMasterPos() error logging
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 19 Jun 2019 02:19:53 +0000 (03:19 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 19 Jun 2019 02:19:53 +0000 (03:19 +0100)
Change-Id: I134e58949bab25e73874ea29d1b306e4fffa6ef9

includes/libs/rdbms/loadbalancer/LoadBalancer.php

index ffb7a34..4787edc 100644 (file)
@@ -1961,12 +1961,15 @@ class LoadBalancer implements ILoadBalancer {
                }
 
                if ( $pos instanceof DBMasterPos ) {
+                       $start = microtime( true );
                        $result = $conn->masterPosWait( $pos, $timeout );
+                       $seconds = max( microtime( true ) - $start, 0 );
                        if ( $result == -1 || is_null( $result ) ) {
-                               $msg = __METHOD__ . ': timed out waiting on {host} pos {pos}';
+                               $msg = __METHOD__ . ': timed out waiting on {host} pos {pos} [{seconds}s]';
                                $this->replLogger->warning( $msg, [
                                        'host' => $conn->getServer(),
                                        'pos' => $pos,
+                                       'seconds' => round( $seconds, 6 ),
                                        'trace' => ( new RuntimeException() )->getTraceAsString()
                                ] );
                                $ok = false;