jenkins-bot has submitted this change and it was merged.
Change subject: Added wfLogDBError() call to LoadBalancer::doWait()
......................................................................
Added wfLogDBError() call to LoadBalancer::doWait()
Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a
---
M includes/GlobalFunctions.php
M includes/db/LoadBalancer.php
2 files changed, 29 insertions(+), 41 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
Aaron Schulz: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index eab8031..81f767d 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1789,52 +1789,37 @@
/**
* 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 = "<ul>\n";
- }
- $backtrace = wfDebugBacktrace();
- foreach ( $backtrace as $call ) {
- if ( isset( $call['file'] ) ) {
- $f = explode( DIRECTORY_SEPARATOR, $call['file'] );
- $file = $f[count( $f ) - 1];
- } else {
- $file = '-';
- }
- if ( isset( $call['line'] ) ) {
- $line = $call['line'];
- } else {
- $line = '-';
- }
- if ( $wgCommandLineMode ) {
- $msg .= "$file line $line calls ";
- } else {
- $msg .= '<li>' . $file . ' line ' . $line . ' calls ';
- }
- if ( !empty( $call['class'] ) ) {
- $msg .= $call['class'] . $call['type'];
- }
- $msg .= $call['function'] . '()';
-
- if ( $wgCommandLineMode ) {
- $msg .= "\n";
- } else {
- $msg .= "</li>\n";
- }
- }
- if ( $wgCommandLineMode ) {
- $msg .= "\n";
- } else {
- $msg .= "</ul>\n";
+ if ( $raw === null ) {
+ $raw = $wgCommandLineMode;
}
- return $msg;
+ if ( $raw ) {
+ $frameFormat = "%s line %s calls %s()\n";
+ $traceFormat = "%s";
+ } else {
+ $frameFormat = "<li>%s line %s calls %s()</li>\n";
+ $traceFormat = "<ul>\n%s</ul>\n";
+ }
+
+ $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 eeb2fec..0fb2d09 100644
--- a/includes/db/LoadBalancer.php
+++ b/includes/db/LoadBalancer.php
@@ -410,7 +410,10 @@
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" );
--
To view, visit https://gerrit.wikimedia.org/r/165024
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits