From: Chad Horohoe Date: Thu, 26 Oct 2017 20:43:49 +0000 (-0700) Subject: rdbms: Group disconnect/reconnect errors by DB server name X-Git-Tag: 1.31.0-rc.0~1656^2 X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=0f3226654343a78c4b58ba3f1032bc031ce7b8eb rdbms: Group disconnect/reconnect errors by DB server name Still allow varying on stacktrace, as those are interesting Change-Id: I62bc3f68fcbe43532dce849d515a5e0620fba6f2 --- diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index c04e167738..a9dd07483f 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -945,10 +945,12 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware # Update state tracking to reflect transaction loss due to disconnection $this->handleSessionLoss(); if ( $this->reconnect() ) { - $msg = __METHOD__ . ": lost connection to {$this->getServer()}; reconnected"; - $this->connLogger->warning( $msg ); + $msg = __METHOD__ . ': lost connection to {dbserver}; reconnected'; + $params = [ 'dbserver' => $this->getServer() ]; + $this->connLogger->warning( $msg, $params ); $this->queryLogger->warning( - "$msg:\n" . ( new RuntimeException() )->getTraceAsString() ); + "$msg:\n" . ( new RuntimeException() )->getTraceAsString(), + $params ); if ( !$recoverable ) { # Callers may catch the exception and continue to use the DB @@ -958,8 +960,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $ret = $this->doProfiledQuery( $sql, $commentedSql, $isNonTempWrite, $fname ); } } else { - $msg = __METHOD__ . ": lost connection to {$this->getServer()} permanently"; - $this->connLogger->error( $msg ); + $msg = __METHOD__ . ': lost connection to {dbserver} permanently'; + $this->connLogger->error( $msg, [ 'dbserver' => $this->getServer() ] ); } } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 8393e2bcfe..1be8926bfa 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -568,7 +568,8 @@ class LoadBalancer implements ILoadBalancer { $knownReachedPos->hasReached( $this->mWaitForPos ) ) { $this->replLogger->debug( __METHOD__ . - ": replica DB $server known to be caught up (pos >= $knownReachedPos)." ); + ': replica DB {dbserver} known to be caught up (pos >= $knownReachedPos).', + [ 'dbserver' => $server ] ); return true; } @@ -576,13 +577,15 @@ class LoadBalancer implements ILoadBalancer { $conn = $this->getAnyOpenConnection( $index ); if ( !$conn ) { if ( !$open ) { - $this->replLogger->debug( __METHOD__ . ": no connection open for $server" ); + $this->replLogger->debug( __METHOD__ . ': no connection open for {dbserver}', + [ 'dbserver' => $server ] ); return false; } else { $conn = $this->openConnection( $index, self::DOMAIN_ANY ); if ( !$conn ) { - $this->replLogger->warning( __METHOD__ . ": failed to connect to $server" ); + $this->replLogger->warning( __METHOD__ . ': failed to connect to {dbserver}', + [ 'dbserver' => $server ] ); return false; } @@ -592,7 +595,8 @@ class LoadBalancer implements ILoadBalancer { } } - $this->replLogger->info( __METHOD__ . ": Waiting for replica DB $server to catch up..." ); + $this->replLogger->info( __METHOD__ . ': Waiting for replica DB {dbserver} to catch up...', + [ 'dbserver' => $server ] ); $timeout = $timeout ?: $this->mWaitTimeout; $result = $conn->masterPosWait( $this->mWaitForPos, $timeout );