From 18e147f39921bfba656f5a86394e02c5be17b811 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 21 Sep 2008 08:28:21 +0000 Subject: [PATCH] Logging tweaks --- includes/db/Database.php | 25 +++++++++++-------------- includes/db/LoadBalancer.php | 2 ++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 0bd77eabda..1fa170752d 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -376,24 +376,21 @@ class Database { $error = $phpError; } wfLogDBError( "Error connecting to {$this->mServer}: $error\n" ); + wfDebug( "DB connection error\n" ); + wfDebug( "Server: $server, User: $user, Password: " . + substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" ); + $success = false; } wfProfileOut("dbconnect-$server"); - if ( $dbName != '' ) { - if ( $this->mConn !== false ) { - $success = @/**/mysql_select_db( $dbName, $this->mConn ); - if ( !$success ) { - $error = "Error selecting database $dbName on server {$this->mServer} " . - "from client host {$wguname['nodename']}\n"; - wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n"); - wfDebug( $error ); - } - } else { - wfDebug( "DB connection error\n" ); - wfDebug( "Server: $server, User: $user, Password: " . - substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" ); - $success = false; + if ( $dbName != '' && $this->mConn !== false ) { + $success = @/**/mysql_select_db( $dbName, $this->mConn ); + if ( !$success ) { + $error = "Error selecting database $dbName on server {$this->mServer} " . + "from client host {$wguname['nodename']}\n"; + wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n"); + wfDebug( $error ); } } else { # Delay USE query diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index cfea8b3597..d0a7343d03 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -663,6 +663,7 @@ class LoadBalancer { $reporting = true; if ( !is_object( $conn ) ) { // No last connection, probably due to all servers being too busy + wfLogDBError( "LB failure with no last connection\n" ); $conn = new Database; if ( $this->mFailFunction ) { $conn->failFunction( $this->mFailFunction ); @@ -678,6 +679,7 @@ class LoadBalancer { $conn->failFunction( false ); } $server = $conn->getProperty( 'mServer' ); + wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" ); $conn->reportConnectionError( "{$this->mLastError} ({$server})" ); } $reporting = false; -- 2.20.1