From: Tim Starling Date: Fri, 23 Jul 2004 12:37:55 +0000 (+0000) Subject: debug output, and proper handling of NULL return from masterPosWait(), which occurs... X-Git-Tag: 1.5.0alpha1~2616 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=3dc56846738f5f8bcda8c0f2bcd0edef880e2b74;p=lhc%2Fweb%2Fwiklou.git debug output, and proper handling of NULL return from masterPosWait(), which occurs if replication is stopped with SLAVE STOP --- diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index 00d2c1d483..b52cabb59d 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -130,6 +130,7 @@ class LoadBalancer { # If a DB_SLAVE connection has been opened already, waits # Otherwise sets a variable telling it to wait if such a connection is opened function waitFor( $file, $pos ) { + wfDebug( "User master pos: $file $pos\n" ); $this->mWaitForFile = false; $this->mWaitForPos = false; @@ -160,14 +161,19 @@ class LoadBalancer { } $conn =& $this->getConnection( $index ); + wfDebug( "Waiting for slave #$index to catch up...\n" ); $result = $conn->masterPosWait( $this->mWaitForFile, $this->mWaitForPos, MASTER_WAIT_TIMEOUT ); - if ( $result == -1 ) { + + if ( $result == -1 || is_null( $result ) ) { # Timed out waiting for slave, use master instead # This is not the ideal solution. If there are a large number of slaves, a slow # replicated write query will cause the master to be swamped with reads. However # that's a relatively graceful failure mode, so it will do for now. + wfDebug( "Timed out waiting for slave #$index pos {$this->mWaitForFile} {$this->mWaitForPos}\n" ); $this->mReadIndex = 0; - } + } else { + wfDebug( "Done\n" ); + } } function &getConnection( $i, $fail = false ) @@ -275,9 +281,11 @@ class LoadBalancer { if ( empty( $this->mConnections[0] ) ) { $conn =& $this->getConnection( DB_SLAVE ); list( $file, $pos ) = $conn->getSlavePos(); + wfDebug( "Saving master pos fetched from slave: $file $pos\n" ); } else { $conn =& $this->getConnection( 0 ); list( $file, $pos ) = $conn->getMasterPos(); + wfDebug( "Saving master pos: $file $pos\n" ); } if ( $file !== false ) { $_SESSION['master_log_file'] = $file;