return false;
}
- # wfDebugLog( 'connect', var_export( $loads, true ) );
-
# Return a random representative of the remainder
return ArrayUtils::pickRandom( $loads );
}
$nonErrorLoads = $this->mGroupLoads[$group];
} else {
# No loads for this group, return false and the caller can use some other group
- wfDebug( __METHOD__ . ": no loads for group $group\n" );
+ wfDebugLog( 'connect', __METHOD__ . ": no loads for group $group\n" );
return false;
}
}
}
$serverName = $this->getServerName( $i );
- wfDebug( __METHOD__ . ": using server $serverName for group '$group'\n" );
+ wfDebugLog( 'connect', __METHOD__ .
+ ": using server $serverName for group '$group'\n" );
}
return $i;
/** @var DBMasterPos $knownReachedPos */
$knownReachedPos = $this->srvCache->get( $key );
if ( $knownReachedPos && $knownReachedPos->hasReached( $this->mWaitForPos ) ) {
- wfDebugLog( 'replication', __METHOD__ . ": Slave $server known to be caught up.\n" );
+ wfDebugLog( 'replication', __METHOD__ .
+ ": slave $server known to be caught up (pos >= $knownReachedPos).\n" );
return true;
}
} else {
$conn = $this->openConnection( $index, '' );
if ( !$conn ) {
- wfDebugLog( 'replication', __METHOD__ . ": failed to open connection to $server\n" );
+ wfDebugLog( 'replication', __METHOD__ . ": failed to connect to $server\n" );
return false;
}
$refCount = $conn->getLBInfo( 'foreignPoolRefCount' );
if ( $serverIndex === null || $refCount === null ) {
wfDebug( __METHOD__ . ": this connection was not opened as a foreign connection\n" );
-
/**
* This can happen in code like:
* foreach ( $dbs as $db ) {
* When a connection to the local DB is opened in this way, reuseConnection()
* should be ignored
*/
-
return;
}
$conn = $this->reallyOpenConnection( $server, false );
$serverName = $this->getServerName( $i );
if ( $conn->isOpen() ) {
- wfDebug( "Connected to database $i at $serverName\n" );
+ wfDebugLog( 'connect', "Connected to database $i at $serverName\n" );
$this->mConns['local'][$i][0] = $conn;
} else {
- wfDebug( "Failed to connect to database $i at $serverName\n" );
+ wfDebugLog( 'connect', "Failed to connect to database $i at $serverName\n" );
$this->mErrorConnection = $conn;
$conn = false;
}
for ( $i = 1; $i < $serverCount; $i++ ) {
$conn = $this->getAnyOpenConnection( $i );
if ( $conn ) {
- wfDebug( "Master pos fetched from slave\n" );
-
return $conn->getSlavePos();
}
}
} else {
- wfDebug( "Master pos fetched from master\n" );
-
return $masterConn->getMasterPos();
}
if ( !$this->laggedSlaveMode && $this->getServerCount() > 1 ) {
try {
// See if laggedSlaveMode gets set
- $this->getConnection( DB_SLAVE, false, $wiki );
+ $conn = $this->getConnection( DB_SLAVE, false, $wiki );
+ $this->reuseConnection( $conn );
} catch ( DBConnectionError $e ) {
// Avoid expensive re-connect attempts and failures
$this->slavesDownMode = true;