From: Aaron Schulz Date: Mon, 6 Oct 2014 17:42:58 +0000 (-0700) Subject: Added wfLogDBError() call to LoadBalancer::doWait() X-Git-Tag: 1.31.0-rc.0~13305 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=fc2e6df64ffabe9236b8b5eee43d3d89e235670a;p=lhc%2Fweb%2Fwiklou.git Added wfLogDBError() call to LoadBalancer::doWait() Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index eab8031c3c..81f767d836 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1789,52 +1789,37 @@ function wfDebugBacktrace( $limit = 0 ) { /** * Get a debug backtrace as a string * + * @param bool|null $raw If true, the return value is plain text. If false, HTML. + * Defaults to $wgCommandLineMode if unset. * @return string + * @since 1.25 Supports $raw parameter. */ -function wfBacktrace() { +function wfBacktrace( $raw = null ) { global $wgCommandLineMode; - if ( $wgCommandLineMode ) { - $msg = ''; - } else { - $msg = "\n"; + $frameFormat = "
  • %s line %s calls %s()
  • \n"; + $traceFormat = "\n"; } - return $msg; + $frames = array_map( function ( $frame ) use ( $frameFormat ) { + $file = !empty( $frame['file'] ) ? basename( $frame['file'] ) : '-'; + $line = $frame['line'] ?: '-'; + $call = $frame['function']; + if ( !empty( $frame['class'] ) ) { + $call = $frame['class'] . $frame['type'] . $call; + } + return sprintf( $frameFormat, $file, $line, $call ); + }, wfDebugBacktrace() ); + + return sprintf( $traceFormat, implode( '', $frames ) ); } /** diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index eeb2fec744..0fb2d094a4 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -410,7 +410,10 @@ class LoadBalancer { if ( $result == -1 || is_null( $result ) ) { # Timed out waiting for slave, use master instead - wfDebug( __METHOD__ . ": Timed out waiting for slave #$index pos {$this->mWaitForPos}\n" ); + $server = $this->mServers[$index]; + $msg = __METHOD__ . ": Timed out waiting on $server pos {$this->mWaitForPos}"; + wfDebug( "$msg\n" ); + wfDebugLog( 'DBPerformance', "$msg:\n" . wfBacktrace( true ) ); $ok = false; } else { wfDebug( __METHOD__ . ": Done\n" );